Skip to content
Limited timeStarter is now $9 a month instead of $20.See plans
charmotion

Animated 404 Page: Formats, Copy-Paste Code and the SEO Rule Not to Break

By the Charmotion team · Updated · How we write guides

Cover illustration for the guide: Animated 404 Page: Formats, Copy-Paste Code and the SEO Rule Not to Break, with Charmotion demo characters

An animated 404 page is a custom error page that adds a small looping animation, such as a mascot looking around, while still returning the HTTP 404 status code. The text, a search box and a few links do the real work; the animation sets the tone. Use a short muted video, Lottie or Rive file with a still fallback.

Key takeaways

  • The page must return a 404 (or 410) status; Google ignores content from 4xx URLs and reports error pages served as 200 as soft 404s.
  • Plain text that explains the problem, a search box and links to key pages matter more than the animation.
  • A muted, looping, inline MP4 with a poster is the simplest option; Rive or Lottie suit interactive or vector characters.
  • Respect prefers-reduced-motion, avoid flashing, and keep loops over five seconds pausable.
  • Check the status with curl after every deploy: hosting defaults can silently turn 404s into 200s.

Already have a character or logo? See examples in real app screens: splash, onboarding, loading and empty-state screens, with the animation that plays in each.

What should an animated 404 page include?

A 404 page exists to get people back on track. Nielsen Norman Group's long-standing advice is to explain in plain language why the page could not be found, without blaming the visitor, and to include "a search field linked to the site's search engine." The animation is a bonus that softens the dead end.

  • A clear heading such as "We can't find that page", in real HTML text, not inside the animation.
  • One sentence of explanation: the link may be old, or the address mistyped.
  • A search box if your site has search.
  • Three to five links: home, your most visited pages, and contact or help.
  • One small animation near the heading. A mascot that shrugs, looks around or waves is enough.

Keep the animation to one element. A full-screen scene makes the page slower to load and pushes the useful links down, which is the opposite of what a lost visitor needs.

How do I make sure my animated 404 page returns a 404 status?

This is the one rule you cannot break. Google states that it does not index URLs that return a 4xx status code and ignores their content, and that when a page's content suggests an error, Search Console reports a soft 404. A pretty error page served with a 200 OK status is exactly that.

Check any missing URL from a terminal:

curl -sI https://example.com/this-page-does-not-exist | head -1
# expected: HTTP/2 404

How to wire the page on common setups:

  • nginx: error_page 404 /404.html; keeps the 404 status. Do not add =200, which changes the response code.
  • Apache: ErrorDocument 404 /404.html. Use a local path: a full URL starting with https: makes Apache redirect instead of serving the page.
  • GitHub Pages: add 404.html (or 404.md) to the publishing source.
  • Cloudflare Pages: add a 404.html. Without one, Pages assumes a single-page app and serves your homepage for every unknown path.
  • Next.js App Router: app/not-found.tsx handles unmatched URLs. Next.js sends a 404 status if it has not started streaming, and injects a noindex meta tag in both cases. Its docs also note that the root not-found file is sent with every route, so keep it a Server Component and do not import a heavy animation library into it.

Which animation format is best for a 404 page?

FormatBest forWatch out for
CSS keyframesBouncing numbers, a floating icon, simple illustrationsHard to animate a detailed character
MP4 (or WebM) videoAny character or scene; no JavaScriptNeeds muted and playsinline to autoplay; transparency needs WebM plus HEVC MOV
GIFQuick drop-in where video is not allowedMuch larger than video for the same clip, 256 colors
Lottie (JSON or .lottie)Vector illustrations that play throughNeeds a player script
Rive (.riv)A character that reacts to the pointer or a clickNeeds the Rive runtime

For most sites a short video loop is the right call: it plays everywhere, needs no script and is easy to swap. Pick Rive when you want the character to react, for example looking toward the search box. See GIF vs WebM vs MP4 vs Rive for file size comparisons and transparent video on a website if the character must sit on a colored background.

How do I add a looping video to a 404 page?

A complete static 404.html with a muted loop, a poster and a still image for visitors who prefer reduced motion:

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Page not found</title>
  <style>
    .still { display: none; }
    @media (prefers-reduced-motion: reduce) {
      .loop { display: none; }
      .still { display: block; }
    }
  </style>
</head>
<body>
  <main>
    <video class="loop" autoplay muted loop playsinline
           width="280" height="280" poster="/404-poster.png" aria-hidden="true">
      <source src="/404-loop.mp4" type="video/mp4">
    </video>
    <img class="still" src="/404-poster.png" width="280" height="280" alt="">
    <h1>We can't find that page</h1>
    <p>The link may be old or mistyped. Try a search or one of these pages.</p>
    <form action="/search" role="search">
      <input type="search" name="q" aria-label="Search the site">
      <button>Search</button>
    </form>
    <ul>
      <li><a href="https://example.com/">Home</a></li>
      <li><a href="https://example.com/blog">Blog</a></li>
      <li><a href="https://example.com/contact">Contact</a></li>
    </ul>
  </main>
</body>
</html>

The animation is decorative, so it is hidden from screen readers with aria-hidden and an empty alt; the heading carries the message. Keep the loop short (2 to 4 seconds) and the file small, and use absolute paths such as /404-loop.mp4, because the page is served at whatever broken URL the visitor typed.

How do I add a Rive or Lottie character to a 404 page?

Rive's web runtime draws a .riv file into a canvas. This version shows a still image as the canvas background, and only starts the animation when the visitor has not asked for reduced motion:

<canvas id="mascot" width="280" height="280" aria-hidden="true"
  style="background: url(/404-poster.png) center / contain no-repeat"></canvas>
<script src="https://unpkg.com/@rive-app/canvas@2.51.0"></script>
<script>
  const canvas = document.getElementById("mascot");
  if (!matchMedia("(prefers-reduced-motion: reduce)").matches) {
    const r = new rive.Rive({
      src: "/404-mascot.riv",
      canvas,
      stateMachines: "State Machine 1", // the name in your file
      autoplay: true,
      onLoad: () => {
        r.resizeDrawingSurfaceToCanvas();
        canvas.style.background = "none";
      },
    });
  }
</script>

For a Lottie illustration, the dotLottie web component is a single tag:

<dotlottie-wc src="/404.lottie" autoplay loop
  style="width: 280px; height: 280px"></dotlottie-wc>
<script type="module"
  src="https://unpkg.com/@lottiefiles/dotlottie-wc@0.12.2/dist/dotlottie-wc.js"></script>

Pin the version numbers as shown so an upstream release cannot change your page. If you want the runtime on your own domain, install the npm package and serve it with your other scripts.

How do I keep an animated 404 page accessible?

  • Honor reduced motion. The prefers-reduced-motion media query reports the operating system setting; both snippets above show a still image when it is on.
  • Let people stop long loops. WCAG 2.2.2 requires a way to pause, stop or hide moving content that starts automatically, lasts more than five seconds and sits next to other content. A short loop that stops after a few cycles, or a pause button, meets it.
  • No flashing. WCAG 2.3.1 sets a limit of three flashes in any one second. Glitch and static effects are a common 404 cliché that can break it.
  • Text stays text. Never put the explanation or the links inside the animation.
  • Keep focus order sensible. The search box and links should be reachable with the keyboard right after the heading.

What animation ideas work on a 404 page?

The best 404 animations are small and on-brand: they say "this is a dead end, but we're still here."

  • Your mascot idling or looking around, as if it is also searching.
  • A wave that greets the visitor, then settles back to idle.
  • A loading or thinking loop next to the search box.
  • A gentle motion on the "404" digits in CSS, if you have no character.

Disclosure: Charmotion is our product. We list it where it fits and say where other tools are better; every other fact links to its source.

If you already have a mascot image, Charmotion turns one PNG, JPEG or WebP into idle (included), wave, happy, launch and loading loops, and gives you a .riv file with web code plus MP4, transparent WebM and MOV exports, so either snippet above works with it. It does not make custom scenes, such as a character digging a hole; for a one-off joke like that, a motion designer or a hand-built Lottie fits better. You can check the live examples before deciding.

Frequently asked questions

Does an animated 404 page hurt SEO?

Not if it returns a real 404 status. Google ignores content on URLs that return 4xx codes, so the animation has no ranking effect either way. The risk is serving the page with a 200 status, which Search Console reports as a soft 404.

Should I redirect all 404s to my homepage instead?

No. Redirect a missing URL with a 301 only when a page with the same content exists at a new address. Sending every broken link to the homepage confuses visitors and hides broken links from your reports.

How big should a 404 animation file be?

As small as you can make it. Export a 2 to 4 second loop at the size it is displayed, without an audio track, and check the result in your browser network panel. A vector .riv or .lottie file is often smaller still.

Can I use a GIF on a 404 page?

Yes, it works everywhere. A muted MP4 loop of the same clip is usually several times smaller and looks better, so prefer video unless your platform only accepts images.

Quick answers from this guide

Sources

Related guides