VHS Effect
A grid of thin dark lines that keeps scrolling over a block, with light grain: the image or title you place underneath looks like a tape being played back.
Updated
This effect is part of Effect.Labs — 846 vanilla effects, some free, some premium. Distortion has 31 effects, including 5 free. Explore the category →
3 usage examples



How it works
Everything happens in .vhsl-screen, a 300×200 px block by default. Its ::before pseudo-element paints a repeating-linear-gradient: 2 px transparent, 2 px of 30 % black, over and over. The vhslScan animation shifts that pattern by 4 px every 0.1 s, endlessly, so the lines seem to slide down like a VCR reading a tape.
On top, .vhsl-noise lays an SVG fractal noise (written as a data: URL inside the CSS, no file to load) at 5 % opacity in overlay mode, and ::after adds an almost invisible light band: a 3 % white gradient whose opacity swings between 3 and 5 %, barely 0.15 % white at its peak. Both layers stay subtle: what you notice first is the line grid. There is no colour shift and no frame jump.
The .vhsl-label text ("PLAY ▶") sits above the lines. An <img class="vhsl-media"> or <video class="vhsl-media"> placed in the screen fills it, under the lines. No JavaScript: it is all CSS, tuned with variables (--vhsl-w, --vhsl-h, --vhsl-bg…).
Accessibility
- Nothing to operate: the effect reacts to neither mouse nor keyboard and adds no focusable element. Any play buttons stay yours.
- Readable text: "PLAY" is real text; the ▶ triangle has
aria-hidden="true"so it is not read out as "black right-pointing triangle". - Reduced motion: under
prefers-reduced-motion: reduce, the lines stop scrolling and the light band stops pulsing; the lines stay on screen, still. - No flashing: the pulsing band never goes above 5 % opacity and the measured average luminance stays flat. On a bright image, still check the contrast of the white label.
Browser compatibility
CSS only, no external resource (the grain is an SVG written inside the CSS). The most recent property is inset (Chrome 87, Firefox 66, Safari 14.1 according to MDN data). Measured in Chromium 151, Firefox 153 and WebKit 26.5: same rendering, two independent copies, nothing added to window, fluid width at 100 %.
Without inset support, the lines and grain no longer cover the screen: the block and its label still show, without the effect. Without mix-blend-mode, the grain simply shows at 5 % opacity.
The code
HTML structure to paste into your page (the CSS + JS come with your purchase):
<div class="fx-0252-root">
<div class="vhsl-screen">
<div class="vhsl-noise" aria-hidden="true"></div>
<span class="vhsl-label">PLAY <span aria-hidden="true">▶</span></span>
</div>
</div>
One-time payment, no subscription — the code is yours forever
Customize
Options passed to the API or data-* attributes:
| Option / property | Default | Effect |
|---|---|---|
Screen size (CSS — --vhsl-w, --vhsl-h) |
300 px × 200 px | 100% fills the parent (with max-width: 100%, the screen never overflows). A 96×32 px tag still shows readable lines. |
Screen background (CSS — --vhsl-bg) |
Gradient #1a1a2e → #16213e |
Any background value: colour, gradient, url(). A semi-transparent colour dims whatever lies behind the root. |
Image or video under the lines (HTML — vhsl-media class) |
None | Put <img class="vhsl-media"> or <video class="vhsl-media"> inside .vhsl-screen: the media covers the screen (object-fit: cover) and sits under the lines and grain. |
Line colour (CSS — --vhsl-line) |
rgba(0, 0, 0, .3) |
Go up to .5 for crisp lines over a bright image; a colour (blue, green) tints the grid. |
Label (HTML — .vhsl-label, CSS — --vhsl-color, --vhsl-size) |
"PLAY ▶", white, 1.5rem, bold | Change the text (PAUSE, REC, a running time); remove the span for lines without text. |
Scroll speed (CSS — vhslScan duration in .vhsl-screen::before) |
0.1 s per 4 px | 0.3 s gives a slow, calm scroll; above 1 s the lines look almost still. |
Surrounding frame (CSS — --vhsl-page, --vhsl-root-h) |
#0a0a0f, at least 300 px tall |
transparent and 0 drop the screen into your layout without the dark demo frame. |
FAQ
<video class="vhsl-media" autoplay muted loop playsinline> tag inside .vhsl-screen fills the frame under the lines. The video keeps its own controls and its own motion setting: the lines do not replace them.prefers-reduced-motion: reduce, the scrolling and the light-band pulse stop; the lines stay visible, still, and the label does not change.