Neon Text Effect in CSS (Glowing Text)
A neon text effect is just text-shadow, stacked several times: a small, bright shadow close to the letters for the tube, and larger, colored shadows for the glow around it. It only works on a dark background, like a real neon sign at night.
Demo:
Open
Late Night
Coding
How the neon glow works
Each text-shadow is x-offset y-offset blur color. With no offset, the shadow sits right behind the text and the blur spreads it into a glow. The small white shadows make the letters look bright, like the tube itself; the large colored ones are the light spilling around it. More layers with bigger blur means a stronger glow.
.neon {
color: #fff;
text-shadow:
0 0 4px #fff, /* bright core */
0 0 10px #fff,
0 0 20px #3b82f6, /* colored glow */
0 0 40px #3b82f6,
0 0 80px #3b82f6; /* wide halo */
}
Flickering neon animation
Real neon signs flicker now and then. Briefly drop the opacity and the shadow at a few irregular points in the animation. Keep it subtle and respect reduced motion: constant flashing is uncomfortable for some people.
.neon--flicker {
animation: flicker 3s infinite;
}
@keyframes flicker {
0%, 18%, 22%, 25%, 53%, 57%, 100% { opacity: 1; }
20%, 24%, 55% { opacity: 0.4; text-shadow: none; }
}
@media (prefers-reduced-motion: reduce) {
.neon--flicker { animation: none; }
}
Neon border box
The same idea works on boxes with box-shadow: an inner and outer glow around a thin border.
.neon-box {
border: 2px solid #fff;
border-radius: 12px;
box-shadow:
0 0 6px #fff,
0 0 16px #3b82f6,
inset 0 0 16px #3b82f6;
}
FAQ
How do I make glowing text in CSS?
Stack several text-shadow layers with no offset and increasing blur, in a bright color, on a dark background.
Which font works best for neon?
Rounded, monoline fonts look most like neon tubes, but the effect works with any bold font.
Is neon text accessible?
Keep it for short headings and decoration. White text with a glow on a dark background has good contrast; avoid flicker for anything important, and turn it off for reduced motion.
Want to fine-tune the glow visually? Use the CSS text shadow generator.
Related: text shadow generator, CSS text stroke, CSS glass effect and CSS tips.