AI CSS Animations

404 Glitch Text

A big 404 whose digits glitch one at a time, jumping, skewing and splitting into red and cyan, above a quiet PAGE NOT FOUND line. Each digit shares one keyframe and has its own delay.

Also known as: 404 page animation css, error 404 glitch, page not found text effect.

404
PAGE NOT FOUND

HTML

<div class="txt-glitch-404" aria-label="404, page not found">
  <div class="txt-glitch-404-code"><span style="--i: 0; --d: 0s">4</span><span style="--i: 1; --d: 0.9s">0</span><span style="--i: 2; --d: 0.45s">4</span></div>
  <div class="txt-glitch-404-msg">PAGE NOT FOUND</div>
</div>

CSS

.txt-glitch-404 {
  --c: var(--txt-color, #3b82f6);
  font-size: var(--txt-size, 32px);
  font-family: system-ui, sans-serif;
  font-weight: 700;
  line-height: 1.2;
  display: inline-block;
  text-align: center;
  color: var(--c);}
.txt-glitch-404-code {
  font-size: 2.4em;
  font-weight: 900;
  line-height: 1;
  letter-spacing: 0.02em;
}
.txt-glitch-404-code span {
  display: inline-block;
  animation: txt-glitch-404-jolt 2.7s steps(1, end) var(--d) infinite;
}
.txt-glitch-404-msg {
  margin-top: 0.35em;
  padding-left: 0.4em;
  font-size: 0.5em;
  font-weight: 600;
  letter-spacing: 0.4em;
  opacity: 0.75;
}
@keyframes txt-glitch-404-jolt {
  0%, 12%, 100% { transform: none; text-shadow: none; opacity: 1; clip-path: none; }
  2%  { transform: translate(-0.04em, -0.05em) skewX(-10deg); text-shadow: -0.05em 0 #ff2d78, 0.05em 0 #00c2ff; }
  4%  { transform: translate(0.05em, 0.02em); text-shadow: 0.06em 0 #ff2d78, -0.04em 0 #00c2ff; clip-path: inset(0 0 45% 0); }
  6%  { transform: scaleY(1.12); opacity: 0.4; }
  8%  { transform: translateX(-0.03em); text-shadow: -0.03em 0 #ff2d78; clip-path: inset(30% 0 0 0); }
  10% { transform: translateX(0.02em) skewX(6deg); text-shadow: 0.03em 0 #00c2ff; }
}

@media (prefers-reduced-motion: reduce) {
  .txt-glitch-404, .txt-glitch-404 *, .txt-glitch-404::before, .txt-glitch-404::after, .txt-glitch-404 *::before, .txt-glitch-404 *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

Customizing this snippet

  • Color: set --txt-color on the element or a parent. Currently previewing #3b82f6.
  • Font size: set --txt-size. Every other dimension is in em, so the whole thing scales together. Currently previewing 40px.
  • Speed: change the duration on the transition or animation shorthand. Staggered delays are relative, so they keep their rhythm.
  • Reduced motion: the rule at the end of the CSS turns the motion off for people who asked their OS for less of it. Keep it.

Similar text animations