How to Create CSS Glow Effects (Neon, Soft, Animated)
Neon box and text glows in CSS, and what animating them costs. In a Chromium trace, 12 buttons pulsing via box-shadow caused 2,353 paints in 3 seconds; the same glow on ::after with an opacity animation caused none.
A Glow Is a Stack of Shadows
A glow is box-shadow with no offset and a growing blur, layered so the inner ring is bright and the outer rings fade:
.neon {
box-shadow:
0 0 5px rgb(0 255 209 / 0.40),
0 0 15px rgb(0 255 209 / 0.20),
0 0 30px rgb(0 255 209 / 0.10);
}
Shadows do not take up layout space, so a 30px glow can be clipped by a parent with overflow: hidden; leave room with padding or margin. On a light background a colored glow barely shows, which is why the effect lives on dark designs.
Glowing Text
.neon-text {
color: #00FFD1;
text-shadow: 0 0 7px rgb(0 255 209 / 0.8), 0 0 20px rgb(0 255 209 / 0.4);
}
Text shadows are ignored by WCAG's contrast formula, so the text color itself must reach 4.5:1 on its background (3:1 for large text); #00FFD1 on #0B0D17 is about 15:1. A wide bright glow behind thin small text lowers legibility, so keep text glows for headings.
Animating a Glow: Measured
A pulsing glow is usually written as keyframes on box-shadow. We traced 3 seconds of 12 pulsing buttons in Chromium with its timeline tracing (October 13, 2026; script in our test folder), against the same glow put on a ::after layer whose opacity is animated instead:
| Version | Paint events in 3 s | Raster time | Style recalcs |
|---|---|---|---|
| Keyframes on box-shadow | 2,353 | 1,618 ms | 181 |
| Fixed glow on ::after, animate opacity | 0 | 0 ms | 0 |
| Static glow (no animation) | 0 | 0 ms | 0 |
Animating the shadow made the browser repaint and re-rasterize the glow on every frame, half the trace's time on a software rasterizer (a GPU shortens it but does not remove it). Animating opacity is handled by the compositor, so after the first frame there was no paint at all.
.glow { position: relative; }
.glow::after {
content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
box-shadow: 0 0 20px rgb(0 255 209 / 0.5), 0 0 50px rgb(0 255 209 / 0.25);
opacity: 0.4; animation: glow 2s ease-in-out infinite alternate;
}
@keyframes glow { to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .glow::after { animation: none; } }
Keep pointer-events: none on the layer so it cannot block clicks, and honor prefers-reduced-motion; WCAG 2.3.3 asks that motion triggered by interaction can be turned off, and a pulse that never stops is the kind of motion people switch off.
The CSS Glow Generator builds box and text glows with live preview; its pulse animates the shadow directly, which is fine for a single button. For many glowing elements, move the glow onto ::after as above.