While box shadows add depth to containers and cards, text-shadow does something different — it adds depth, legibility, and personality directly to your typography. Whether you want a subtle readability boost for text on complex backgrounds or a bold neon sign effect, text-shadow is the tool for the job.
This guide covers the text-shadow property from syntax to advanced techniques, with practical patterns you can copy into your projects today.
The syntax mirrors box-shadow but is simpler — there is no spread value and no inset option:
text-shadow: [offset-x] [offset-y] [blur] [color];
Like box-shadow, you can stack multiple shadows by separating them with commas.
One of the most practical uses of text-shadow is making text readable over busy or variable backgrounds — hero images, video overlays, and gradient backgrounds.
/* Subtle depth for light text on dark images */
.hero-text {
color: #fff;
text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}
/* Soft halo for dark text on light images */
.overlay-text {
color: #1a1a2e;
text-shadow: 0 0 12px rgba(255, 255, 255, 0.6);
}
For maximum readability on any background, use two shadow layers: one tight and dark for contrast, one wider for a subtle halo:
text-shadow: 0 1px 3px rgba(0,0,0,0.8),
0 0 20px rgba(0,0,0,0.3);
This technique is used by major websites for hero text over images. It works because the tight shadow provides edge contrast while the wide shadow smooths out any remaining readability issues.
Large blur with a vivid color creates a neon sign effect. Multiple layers increase intensity:
.neon-text {
color: #0ff;
text-shadow:
0 0 7px #0ff,
0 0 10px #0ff,
0 0 21px #0ff,
0 0 42px #0fa,
0 0 82px #0fa;
}
Offset shadow without blur creates a retro, printed look:
.retro-text {
color: #f5e6d3;
text-shadow: 3px 3px 0 #c0392b;
}
Stack multiple shadows with increasing offsets to simulate extruded 3D text:
.text-3d {
color: #f1f5f9;
text-shadow:
1px 1px 0 #64748b,
2px 2px 0 #64748b,
3px 3px 0 #475569,
4px 4px 0 #334155,
5px 5px 10px rgba(0,0,0,0.4);
}
Popular in flat design, the long shadow extends diagonally from the text:
.long-shadow {
color: #fbbf24;
text-shadow:
1px 1px 0 #b45309,
2px 2px 0 #b45309,
3px 3px 0 #92400e,
/* ... repeat up to ~20px */
20px 20px 0 #451a03;
}
A combination of a white glow and slight blur creates a frosted glass appearance:
.frosted {
color: rgba(255,255,255,0.9);
text-shadow: 0 0 20px rgba(255,255,255,0.4);
}
While text-shadow can improve readability, it can also harm it if used carelessly. Here are the guidelines:
prefers-reduced-motion by disabling or simplifying the animation./* Accessibility: respect user preferences */
@media (prefers-reduced-motion: reduce) {
.animated-text {
text-shadow: none;
}
}
Text-shadow animations can create attention-grabbing effects, but they are expensive because they trigger repaints on every frame.
@keyframes pulse-glow {
0%, 100% { text-shadow: 0 0 5px #8b5cf6, 0 0 10px #8b5cf6; }
50% { text-shadow: 0 0 20px #8b5cf6, 0 0 40px #8b5cf6; }
}
.glow-pulse { animation: pulse-glow 2s ease-in-out infinite; }
If you need a glowing animation that performs well, consider using filter: drop-shadow() on a pseudo-element, or animate opacity on a blurred copy of the text behind the original.
For text, text-shadow is almost always the better choice because it is more performant and specifically designed for text. However, filter: drop-shadow() can be useful when you want the shadow to follow the exact shape of text that has been clipped, masked, or composited with non-standard techniques.
Tweaking text-shadow values by hand and reloading the browser is tedious, especially for multi-layer effects. A visual generator lets you adjust each parameter with sliders, see changes in real time, and copy the final CSS.
RiseTop's CSS Text Shadow Generator supports multiple layers, preset effects (neon, retro, 3D, long shadow, glow), color picking with opacity, and instant CSS output. It is the fastest way to go from idea to production code.
prefers-reduced-motion for animated shadowsText shadow is one of those CSS properties that seems simple on the surface but offers incredible creative depth. From practical readability improvements to eye-catching neon effects, mastering text-shadow gives you another powerful tool in your design toolkit. Use a visual generator to experiment freely, then refine the values in your code for the perfect result.
Try our free CSS Text Shadow Generator — design, preview, and copy production-ready CSS instantly.
Open CSS Text Shadow Generator →