The anatomy of a text shadow
text-shadow: offset-x offset-y blur color — and unlike box-shadow, it follows the exact shape of each glyph, not a rectangle. There’s no spread or inset. The real power comes from stacking comma-separated shadows, which are painted front-to-back (first on top):
| Effect | Recipe |
|---|---|
| Soft depth | 1px 1px 2px rgba(0,0,0,0.3) |
| Neon glow | same color, 0 0 offset, increasing blur ×3 |
| Hard outline | four ±1px ±1px 0 color shadows |
| 3D / extrude | stacked incremental offsets in one color |
For a neon sign: 0 0 10px #0ff, 0 0 20px #0ff, 0 0 40px #0ff on bright text over a dark background — the layered blurs build a glowing halo.
Readability is the real job
Decorative shadows are fun, but text-shadow’s most valuable use is legibility over imagery (see FAQ): a faint dark shadow rescues light text from washing out on a bright photo. Keep it subtle — heavy shadows reduce readability rather than improve it, especially on small or thin text. The goal is just enough separation that the eye locks onto the letters.
Rendering pitfalls
- Jagged on retina — very small blur values (0–1px) with strong color can look choppy on high-DPI screens; bump the blur to ≥2px for smoothness, or use exact integer offsets for crisp hard shadows.
- Shadow hidden behind text — a
0 0offset with tiny blur sits entirely under the glyph and shows nothing; add offset or more blur so it extends past the edges. - Order matters — a large opaque shadow listed first can cover smaller ones; reorder or lower its opacity.
Tune offset, blur, color, and opacity per layer with the live preview here, then stack a couple of the generated shadows for richer effects. For card and container elevation (rectangular shadows), reach for the Box Shadow Generator instead.