This is a CSS CRT effect: text glowing on an old tube monitor behind curved glass, with scanlines, a fine RGB phosphor mask, a soft band rolling down, a flicker with a sync slip โ and now and then the power goes off: the picture collapses into a line, the line into a white-hot dot, and the dot slowly fades, just like a real CRT. It's pure CSS, no JavaScript and no canvas, and every setting is a CSS variable you can change live. Below: how each layer works, the settings, and the traps.
Why this effect
Most CRT effects are green or white terminal text. I wanted the screen to glow like a neon tube instead โ warm yellow phosphor, a hot pale core and a red and blue fringe where the beams don't quite line up. The part I always wait for is the power-off: the picture squeezes into a bright line, the line into a white-hot dot, and the dot glows for a moment before it fades. Everyone who has turned off an old TV knows that moment.
What you'll build
A rounded dark screen in a thin bezel, with edges that fall into shadow like curved glass and a faint reflection in the corner. The letters glow in three layers, thin scanlines and red, green and blue phosphor stripes run over everything, a faint bright band rolls down every 6 seconds, and now and then the brightness dips and the picture slips sideways for a moment. After a few seconds the screen switches off โ line, hot dot, afterglow, darkness โ and switches back on. Everything scales with the text size, so the same screen fits a short word or a long title.
How the CRT effect works
1. The screen: curved glass in a bezel
The wrapper is the screen. overflow: hidden keeps the scanlines and the rolling band inside it, and an elliptical border-radius makes it look like a tube โ wider than it is tall. CSS can't bend the glass, but light can fake it: an inset shadow darkens the edges the way a curved tube falls away from you, and a soft white ellipse in the top left corner is the room reflected in the glass. Two thin outer shadows are the bezel, and one wide, faint shadow in the glow colour is the light the screen throws on the wall.
.cr-crt {
position: relative;
overflow: hidden;
padding: 1.15em 0.55em;
border-radius: 0.4em / 0.6em;
background:
radial-gradient(ellipse 60% 45% at 28% 18%, rgb(255 255 255 / 0.07), transparent 70%),
radial-gradient(color-mix(in srgb, var(--cr-glow) 15%, #030405), #030405 80%);
box-shadow:
inset 0 0 0.5em 0.12em rgb(0 0 0 / 0.9), /* curved glass */
0 0 0 0.05em #0b0b0c, /* bezel */
0 0 0 0.065em #1d1e21,
0 0 1.2em color-mix(in srgb, var(--cr-glow) 14%, transparent); /* light on the wall */
}
Padding, radius and shadows are in em, and the screen's font-size is the text size โ so a bigger word gets a bigger screen automatically.
2. Phosphor: a hot core and two colour fringes
On a real CRT three electron beams draw red, green and blue. When they are slightly out of line, the edges of the letters get colour fringes. Two hard text-shadows do that: red one way, blue the other. Then three soft shadows make the glow โ tight, medium and a wide warm halo.
.cr-crt > * {
color: #fff8c2;
text-shadow:
-2px 0 rgb(255 0 0 / 0.7),
2px 0 rgb(0 0 255 / 0.7),
0 0 0.12em #ffe600,
0 0 0.28em #ffd000,
0 0 0.67em #ff9e00;
}
3. CSS scanlines and a phosphor mask
Scanlines are a repeating-linear-gradient on a ::before that covers the whole screen: 2px clear, 2px darker, repeated. Over them goes a second gradient, sideways: 1px stripes of red, green and blue โ the phosphor mask a real tube draws its picture through. Look closely at an old monitor and you see exactly these stripes.
The trick is mix-blend-mode: multiply. Multiply can only darken: white lets everything through, and a reddish stripe lets red through and dims green and blue. So the layer works as a filter in front of the picture, not as paint on top of it.
.cr-crt::before {
content: "";
position: absolute;
inset: 0;
z-index: 1;
pointer-events: none;
mix-blend-mode: multiply;
background:
repeating-linear-gradient(#fff 0 2px, rgb(255 255 255 / 0.7) 2px 4px),
repeating-linear-gradient(90deg,
#fff0f0 0 1px, #f0fff0 1px 2px, #f0f0ff 2px 3px);
}
pointer-events: none keeps the text selectable and clickable under the layer. The lines and stripes stay in px on purpose: they are the screen's pixels, not part of the text, so they keep the same fine pitch at any size.
4. The rolling band and the flicker
A real CRT often shows a slow bright band crawling down the picture. Here it's a gradient 30% tall on the ::after, moved with background-position. For a background smaller than its box, the percentage counts the free space, so -43% puts the band just above the glass and 143% just below.
.cr-crt::after {
inset: 0;
background: linear-gradient(transparent, rgb(255 255 255 / 0.06), transparent)
0 -43% / 100% 30% no-repeat;
animation: cr-roll 6s linear infinite;
}
@keyframes cr-roll { to { background-position: 0 143%; } }
The letters also breathe: opacity drifts to 0.92, dips to 0.75 โ and at that moment the picture slips sideways, the way a CRT loses sync for a frame: a jerk to the right, a smaller swing back, a tiny one again, and it settles.
@keyframes cr-flicker {
0%, 50%, 59%, 100% { transform: none; }
53% { opacity: 0.75; transform: translateX(0.03em); }
55% { transform: translateX(-0.015em); }
57% { transform: translateX(0.006em); }
}
5. Power-off: a line, a hot dot, afterglow
The whole screen is squashed with scale(): first vertically to a thin line (scaleY(0.006)), then horizontally into a dot. While it shrinks, brightness(3) makes the line burn โ the energy of the whole picture is now in one strip โ and the dot burns even brighter. The border-radius turns into 50% on the way, so the line gets round ends and the dot is round; the bezel and the glass shadow fade, because a collapsed picture is just light.
A tiny copy of the picture still doesn't look like a dot, so the ::after gets one more layer: a white radial gradient whose opacity follows the dot stage. The dot then fades over almost a second, slower than everything else โ that's the phosphor's afterglow. Power-on is the same in reverse: a line stretches out and opens into the picture.
In the video version it's simple keyframes, and it stops at a line and a dot:
@keyframes power {
0%, 70%, 100% { transform: none; filter: none; }
76% { transform: scale(1, .006); filter: brightness(3); }
80% { transform: scale(0, .006); filter: brightness(3); }
86% { transform: scale(0, .006); }
93% { transform: scale(1, .006); filter: brightness(2); }
}
6. A pause you can change: keyframes turned into formulas
With keyframes, a longer pause would stretch the power-off too. So the full version uses a clock instead: --cr-t runs from 0 to 1 once per cycle (@property makes it animatable), and --cr-s is the number of seconds into the power-off โ negative while the screen is on. Each stage is a 0 โ 1 ramp with clamp(), smoothed with xยฒ(3 โ 2x) so it starts and stops softly, like ease-in-out:
--cr-s: calc(var(--cr-t) * (var(--cr-pause) + 2.6) - var(--cr-pause));
--cr-a: clamp(0, var(--cr-s) / 0.4, 1); /* squash into a line */
--cr-ea: calc(var(--cr-a) * var(--cr-a) * (3 - 2 * var(--cr-a)));
Now --cr-pause changes only how long the screen stays on; the power-off always takes 2.6 seconds. The same clock trick is explained step by step in How to Add a Pause Between CSS Animation Loops.
Make it yours
| Variable | What it does |
|---|---|
--cr-pause |
Seconds the screen stays on before the next power-off. |
--cr-lines |
Scanline darkness: 0 turns them off, 0.5 is a heavy old set. |
--cr-mask |
Strength of the red, green and blue phosphor stripes. 0 is smooth glass. |
--cr-fringe |
How far the red and blue fringes stick out. 0 is a perfect tube. |
--cr-size |
Text size; the screen's padding, corners and bezel follow it. |
--cr-core, --cr-glow, --cr-halo |
The phosphor: hot centre, glow, outer halo. Green #d8ffd0 / #39ff14 / #00a020 gives the classic terminal. |
Spacing: padding is the glass around the text (in em, so it grows with the text); margin: 0 is the space around the screen on your page โ set your own.
Gotchas
- The pause is a
<number>, not a time: write--cr-pause: 8, not8s. It goes intocalc()with other numbers. @propertyis needed for the clock. Browsers without it (very old ones) show the screen without the power-off; the rest still works.- Scanlines and zoom: at browser zoom or on some phone screens a 2px pitch or the 1px stripes can shimmer (moirรฉ). If they do, use
3px/6pxlines and set--cr-mask: 0. - Many screens on a page: each one animates
filter, which is not free. A few are fine; for a grid of them, drop the power-off or run it on hover.
Accessibility
The text is real text: selectable, readable by screen readers and search engines. With prefers-reduced-motion: reduce the flicker, the rolling band and the power-off stop โ the screen just glows behind its glass.
Variations
- Neon without the screen, with one flickering letter: Neon Sign.
- Green terminal text that types itself: Typewriter โ put it inside
.cr-crtfor a full retro monitor. - Decrypting text for the same terminal: Scramble Text.
FAQ
How do I make a CRT effect in CSS?
Put the text in a dark rounded box with overflow: hidden, give the letters a pale colour with red and blue text-shadow fringes and a soft glow, darken the edges with an inset box-shadow, and lay scanlines over it with a repeating-linear-gradient on a pseudo-element. A rolling band, a flicker and a scale() power-off make it feel alive. No JavaScript needed.
How do I make CSS scanlines?
One gradient on a pseudo-element that covers the element: repeating-linear-gradient(transparent 0 2px, rgb(0 0 0 / 0.25) 2px 4px). Set pointer-events: none so it doesn't block clicks, and keep the pitch in px. For the RGB phosphor look, add sideways red, green and blue stripes and blend the layer with mix-blend-mode: multiply.
How do I make a CRT turn-off animation in CSS?
Scale the screen to scale(1, 0.006) โ a thin line โ then shrink it into a small round dot while raising filter: brightness() to 3โ5, and let the dot fade slowly, like phosphor afterglow.
Can I use this CRT effect on a whole website?
Yes โ put the .cr-crt class on a big container instead of a heading. Keep the power-off rare (a long --cr-pause) or turn it off, so the page stays usable, and remember the reduced-motion rule.