This is a flickering neon text effect in CSS that behaves like a real, slightly broken sign: it lights up at once, the tired tube sparks, then the sign burns steadily — and every few seconds one tired tube stutters or goes out for a moment. The glow is four text shadows, the flicker is steps(1) keyframes, and a 25-line script adds the randomness. Below: how a neon tube is built, why steps() matters, the settings and the gotchas.
Why this effect
I spent a long time getting plain text shadows to flicker like a real neon lamp — not a blinking light, but a tube that catches unevenly, burns, and once in a while gives up for a second. That little failure is what makes it feel alive. The neon in my warehouse app works the same way, and people notice it even if they can't say why. One tired letter on a calm sign beats a whole word blinking at you.
What you'll build
A word made of glowing glass tubes. The colour, the glow strength and the pause between flickers are CSS variables, so the same code gives a calm bar sign or a nervous motel sign.
How the neon flicker works
1. A tube is a hot core plus a halo
Real neon has a nearly white core and coloured light around it. So the letter itself is a pale yellow, and four text-shadow layers do the glow — tight and strong near the letter, wide and warmer far away:
h1 {
color: #fff8c2;
text-shadow:
0 0 4px #ffe600,
0 0 14px #ffe600,
0 0 34px #ffd000,
0 0 80px #ff9e00;
}
2. A dead tube is still visible
When a neon letter goes out, the glass doesn't vanish — you see a dim, cold shape. That's what makes the flicker believable. The "off" state keeps the letter at about 14% of the tube colour and removes the shadows:
3. Neon snaps, it doesn't fade
A normal animation smoothly blends between keyframes, and a flicker made that way looks like a dimmer switch. A gas tube is either lit or not. steps(1) makes every keyframe jump instantly:
i { animation: tube 9s steps(1) var(--d) infinite backwards; }
@keyframes tube {
0%, 5%, 9%, 15%, 81%, 90%, 100% { /* off */ }
3%, 8%, 14%, 18%, 82% { /* on */ }
}
Each letter gets its own delay --d, so the word catches unevenly when it switches on, the way a real sign does.
4. One faulty letter
A sign where everything blinks together looks like a cheap GIF. In real life one tube is tired. In the video version, the third letter simply runs its cycle in 3.3 seconds instead of 9 — so it never stays in sync with its neighbours:
i:nth-child(3) { animation-duration: 3.3s; }
5. Random flickers with a real pause (a little JS)
A CSS loop repeats exactly, and after a minute your eye notices the pattern. Real signs fail at random. The customizable version keeps all the looks in CSS and adds a short script that:
- splits the word from
data-textinto letters (so you can type any word); - picks one "faulty" letter that gets most of the failures;
- right after the start, makes the faulty letter spark: on → off → a bright flash → off → on, in about a second — the sign is never dark at the start;
- every
--ns-pauseseconds (randomly ±40%) adds a class for a quick stutter or a full die-and-catch, then removes it.
One more touch from real tubes: when a letter catches again, the gas flares up for a moment. A 0.2-second filter: brightness(1.1) swell, started the very moment the letter lights up again, gives exactly that:
@keyframes ns-flare {
50% { filter: brightness(1.1); }
}
function next() {
const pause = parseFloat(getComputedStyle(sign).getPropertyValue("--ns-pause")) || 4;
setTimeout(flicker, pause * 1000 * (0.6 + Math.random() * 0.8));
}
The pause is read from CSS every time, so changing the variable changes the rhythm on the fly. For a regular rhythm without JS, see how to add a pause between CSS animation loops.
Make it yours
| Variable | Default | What it changes |
|---|---|---|
--ns-color |
#ffe600 |
Tube colour. The core is mixed from it and white automatically. |
--ns-halo |
#ff9e00 |
The wide outer glow. A warmer shade than the tube looks most real. |
--ns-glow |
1 |
Glow strength: 0.5 is a shop window, 2 is a foggy night. |
--ns-pause |
4 |
Seconds between flickers on average. 10–20 for a calm site header. |
--ns-size |
120px |
Text size. |
To change the word, change both the text and data-text. A | starts a new line: data-text="SEND|MONEY" gives a two-line sign.
Gotchas
- Use a dark background. Neon glow is light added on top; on white it simply disappears.
- Leave room for the glow. The 80px shadow spills outside the letters — don't put the sign in a container with
overflow: hiddenand no padding. - Many big shadows cost paint time. One sign is nothing; fifty glowing list items animating at once will make a phone sweat. Keep flickers rare and on small numbers of elements.
letter-spacingmatters. Tubes are separate pieces of glass; around 0.1em gives them air.
Accessibility
The flicker is rare and short, but it's still motion, so with prefers-reduced-motion the sign simply burns. The script sets aria-label with the whole word and hides the single letters from screen readers, so the word is read once, not spelled.
Variations
- A sign turning on. Letters catching one by one, each with its own delay — that is the video version (
--don every letter); run it once for a logo entrance. - Pulsating glow. No flicker at all — the sign slowly breathes. Animate only the wide shadows, smoothly:
h1 { animation: pulse 3s ease-in-out infinite alternate; }
@keyframes pulse { to { text-shadow: 0 0 4px #ffe600, 0 0 10px #ffe600, 0 0 20px #ffd000, 0 0 40px #ff9e00; } }
- Subtle flicker. The whole word dips by a fifth for a few frames now and then, instead of dying — calm enough for a site header:
h1 { animation: subtle 6s steps(1) infinite; }
@keyframes subtle { 40%, 43%, 88% { opacity: 0.8; } 41%, 44%, 89% { opacity: 1; } }
- Other colours. Pink-red, cold blue, warm white: change
--ns-colorand--ns-halotogether. - Add a chromatic glitch. A tube dying with a short RGB split is a nice combination — see Chromatic Wave.
FAQ
Can I make a neon flicker without JavaScript?
Yes — the video version is pure CSS: text shadows for the glow, steps(1) keyframes for the flicker and a different duration for the faulty letter. The script only adds randomness, a real pause and any word you type.
Why does my neon text look blurry instead of glowing?
The letter colour is too dark. A real tube has a near-white core; keep the text colour pale and let the shadows carry the colour.
Does text-shadow animation hurt performance?
On a single heading — no. Animating shadows on many large elements repaints a lot of pixels each frame, so keep it to a few letters at a time, as this effect does.
Which font looks most like neon?
Real neon is bent glass tubes of the same thickness, so look for fonts with even, rounded strokes and no sharp contrast: a bold rounded sans works, and on Google Fonts, Monoton (outlined tubes) and Neonderthaw (handwritten script) are made for it. Keep letter-spacing around 0.1em so the tubes don't touch.
Can I download the neon sign as a video or GIF?
Yes. Under the live preview, "Download your sign" makes an MP4 (30 fps, one seamless 5 or 10 s loop), a GIF or a PNG in 9:16, 1:1 or 16:9 — with your text, colours and glow, ready for Reels, TikTok, Shorts or CapCut. It is drawn in your browser; nothing is uploaded. "Copy live link" gives a link that opens the same sign.
Can I copy and paste the neon text?
Yes. Type your word in "Your text", pick the colour, glow and pause with the sliders, then copy the HTML, CSS and JS with the buttons at the top of the page or download them as a .zip.