CSS Glitch Text Effect

Design an animated glitch heading for your website. Pick the colors, size and motion, preview it live and copy the HTML and CSS.

Motion that runs for more than five seconds needs a way to stop it (WCAG 2.2.2), so a short run is the safest choice.

GLITCH

How to use the CSS glitch text effect generator

  1. Type your heading text.
  2. Set the font size, the offset (how far the colored copies shift) and the cycle length (how long each glitch cycle takes).
  3. Pick the text color and the two channel colors. Cyan and magenta give the classic “broken screen” look.
  4. Choose how the animation plays. Play 3 times, then stop is the most accessible choice.
  5. Copy the HTML into your page and the CSS into your stylesheet.

How the effect works

The heading is shown three times. The real text sits in the middle. Two copies are drawn on top with the ::before and ::after pseudo-elements, using content: attr(data-text) to repeat the heading. Each copy is shifted a few pixels left or right and given a colored shadow, like a misaligned color channel on an old screen.

The glitch itself comes from clip-path: inset(). It cuts each copy down to a thin horizontal slice. The keyframe animation moves the slice up and down, so different strips of the text jump out of line. Our CSS glitch text effect tutorial walks through the code line by line.

Accessibility built in

  • No double reading. The copies use content: attr(data-text) / "", which gives the generated text an empty alternative so screen readers read the heading once. Browsers that do not understand this syntax use the line before it.
  • Reduced motion. A prefers-reduced-motion media query stops the animation for visitors who ask their device for less motion.
  • A way to stop. Under WCAG 2.2.2, motion that starts by itself and runs for more than five seconds needs a way to pause it. Playing three short cycles, or only on hover, avoids the problem.
  • Real text. The heading stays plain text, so it is searchable, selectable and translatable.

Keep the effect to one short heading per page, and do not make it flash. Rapid flashing of large areas can trigger seizures, and WCAG asks for no more than three flashes per second.

Frequently asked questions

Does it need JavaScript?

No. The effect is pure HTML and CSS. JavaScript is only used on this page to build the preview.

Can I use a different font?

Yes. Change the font line in the .glitch rule. Heavy, wide fonts show the effect best.

Can I use it on more than one heading?

Yes. Add the glitch class and a matching data-text attribute to each one. The data-text value must match the heading text exactly.

Share this

More text tools