CSS Shadows
Shadow is the cheapest realism in CSS: one property for boxes, one for text, zero images. Learn the value order, the rgba habit, and layering — then depth becomes a dial you turn.
1. box-shadow and text-shadow
.card {
box-shadow: 0 8px 20px -6px rgba(32,36,42,.25);
/* x y blur spread color */
}
h1 {
text-shadow: 0 2px 4px rgba(0,0,0,.3);
/* x y blur color (no spread) */
}Order is offset-x, offset-y, blur, (box only) spread, color. Realistic light comes from above: small positive y, generous blur, translucent rgba() black. Add inset to box-shadow for pressed, carved looks.
2. Layering and glow
.panel {
box-shadow:
0 1px 2px rgba(32,36,42,.08),
0 8px 16px rgba(32,36,42,.10),
0 24px 48px rgba(32,36,42,.12);
}
.neon {
color: #fff;
text-shadow: 0 0 6px #7FD9E0, 0 0 16px #4FB2C4, 0 0 30px #2E7E92;
}Multiple shadows stack with commas, first on top. Tight-dark + wide-soft imitates real light falloff; zero-offset colored layers become glow — the entire neon-sign aesthetic is stacked text-shadows.
3. Try it yourself
Lift the card with 0 12px 24px -8px rgba(32,36,42,.3), press the input with an inset shadow, and give the heading a soft text-shadow.
4. Quiz — check your understanding
CSS Shadows Quiz
4 questions · pass at 60%Q1. In box-shadow: 0 8px 20px -6px …, the -6px is…
Q2. text-shadow differs from box-shadow because it…
Q3. Realistic UI shadows usually use…
Q4. The neon glow effect is built from…
Every lesson quiz you pass (60%+) is saved in your browser and counts toward the CSSmatic Certificate of Completion.