CSS Glitch Text

A cyberpunk glitch effect with offset red and cyan slices.

  • glitch
  • cyberpunk
  • clip-path
  • animation
  • dark
HTML
<h2 class="glitch" data-text="GLITCH">GLITCH</h2>
CSS
.glitch {
  position: relative;
  margin: 0;
  color: #fff;
  font: 900 52px/1 system-ui, sans-serif;
  letter-spacing: 0.04em;
}

.glitch::before,
.glitch::after {
  content: attr(data-text);
  position: absolute;
  top: 0;
  width: 100%;
  background: #0f0f12; /* match your page background */
}

.glitch::before {
  left: 2px;
  text-shadow: -2px 0 #f43f5e;
  animation: glitch-a 2.5s infinite linear alternate-reverse;
}

.glitch::after {
  left: -2px;
  text-shadow: 2px 0 #22d3ee;
  animation: glitch-b 3s infinite linear alternate-reverse;
}

@keyframes glitch-a {
  0% { clip-path: inset(10% 0 80% 0); }
  20% { clip-path: inset(60% 0 20% 0); }
  40% { clip-path: inset(30% 0 50% 0); }
  60% { clip-path: inset(80% 0 5% 0); }
  80% { clip-path: inset(15% 0 70% 0); }
  100% { clip-path: inset(45% 0 40% 0); }
}

@keyframes glitch-b {
  0% { clip-path: inset(70% 0 10% 0); }
  25% { clip-path: inset(20% 0 65% 0); }
  50% { clip-path: inset(50% 0 30% 0); }
  75% { clip-path: inset(5% 0 85% 0); }
  100% { clip-path: inset(85% 0 2% 0); }
}

@media (prefers-reduced-motion: reduce) {
  .glitch::before,
  .glitch::after {
    display: none;
  }
}

About this CSS Glitch Text

This CSS Glitch Text is 52 lines of pure CSS (1.1 KB) with no JavaScript and no dependencies. It uses keyframe animations, text shadows, clip paths and reduced-motion support. It works in current versions of Chrome, Edge, Safari and Firefox. It works in any stack: plain HTML, React, Vue, Svelte, Astro, WordPress or Webflow.

CSS features used

Customize it

The colors in this snippet. Search and replace them to match your brand:

  • #fff
  • #0f0f12
  • #f43f5e
  • #22d3ee

How to use this glitch text

  1. Copy the HTML and paste it where you want the element to appear.
  2. Copy the CSS into your stylesheet, or inside a <style> tag.
  3. Keep the .glitch class name, or rename it in both places. Then tweak colors, sizes and timing to match your design.
  4. Using React or Next.js? Change class to className in the HTML. The CSS works as is, including in Tailwind projects (put it in your global stylesheet).

Building with an AI tool?

“Copy for AI” copies a short prompt for Cursor, Claude Code, Lovable, Bolt or v0. Your AI tool opens the Markdown version of this snippet and reads the HTML, CSS and setup notes there. If your tool can't open links, with the code instead. More ways to use copy CSS with AI.

Feedback