Skip to content

Animated 404 Page

Playful full-page 404 error template with a floating planet, short message, site search field and home link in pure CSS.

Also known as: 404 error page, not found page design, broken link page

Animated 404 Page live demo

Open in new tab

Pure CSS code (HTML, CSS)

A playful full-page 404 error template in pure CSS, where the zero of "404" is a ringed planet floating in a pastel sky. It includes a short message, a site search field and a link back to the home page, so visitors who hit a broken link have a clear way forward. No JavaScript and no images are needed.

How it works

The root main.nf-page fills the viewport with min-height: 100vh and centers .nf-content with display: grid and place-items: center. Behind it, .nf-sky holds six .nf-star sparkles drawn with clip-path that twinkle at different delays. The large .nf-code line contains two .nf-digit elements and an .nf-planet with an inline SVG: an .nf-ring-back ellipse, the .nf-globe with .nf-crater circles and an .nf-ring-front arc drawn on top, which makes the ring appear to wrap around the planet. The SVG floats and tilts with the nf-float keyframes, the digits bob gently out of phase, and .nf-shadow below the planet shrinks as it rises.

The .nf-title heading, .nf-text paragraph, the form.nf-search and the .nf-home link follow. The form is a normal GET request to /search with the field name q, so it works with most site search setups without any script. The heading size and the big digits scale with clamp(), so the layout fits from small phones to wide screens.

Customization

  • --nf-bg-top and --nf-bg-bottom on .nf-page: the two colors of the background gradient.
  • --nf-planet and --nf-planet-dark: the planet body and crater colors; --nf-ring recolors the ring and the shadow.
  • --nf-accent and --nf-accent-hover: the search button, the stars and the focus outlines.
  • --nf-float-distance: how far the planet rises, e.g. 30px for a bigger float.
  • --nf-float-speed: duration of one float cycle; lower values feel livelier.
  • action="/search" and name="q" on .nf-search: point them to your own search URL and query parameter.
  • href="/" on .nf-home: the home page or any other safe landing page.

Use cases

  • Websites with broken links: visitors see a friendly message instead of a blank error
  • Content sites: a site search field helps lost visitors find the page they wanted
  • Any website: a link back to the home page gives a clear way forward
  • Playful brands: a floating ringed planet turns the zero in 404 into a small scene

Accessibility

The decorative "404" and the sky are aria-hidden, and the h1 includes visually hidden "Error 404:" text in an .nf-sr span, so screen reader users hear the full error. The form has role="search", a real label for the input and a visually hidden "Search" name on the icon button. The search pill, button and home link show a clear violet focus outline. Text colors are dark indigo on a light background for strong contrast. With prefers-reduced-motion: reduce all floating and twinkling animations are switched off.

Usage notes

This is a full-page template, so style.css resets the body margin. Make sure your server also returns the HTTP status 404 for this page, not 200, so search engines do not index it.

Animated 404 Page at a glance

Framework
Pure CSS
Code
HTML, CSS
JavaScript
Not needed, CSS only
Dependencies
None
Layout
Responsive, works on mobile
Category
Error Pages
License
Free for personal and commercial use

Questions about this template

Can I use the Animated 404 Page code for free?

Yes. You can copy or download the code and use it in personal and commercial projects, including client work. No sign-up is needed. Reselling it as part of a component library or template collection is not allowed; see the license.

How do I add it to my website?

There is nothing to install. Paste the HTML where the component should appear and add the CSS to your stylesheet. Download HTML gives you a complete page with everything already linked.

Does it need jQuery or a JavaScript framework?

No. It is built with HTML and CSS only, so there is no JavaScript to load.

Does it work on mobile?

Yes. The layout adapts to small screens. Use the Mobile and Tablet buttons above the live demo to check it at phone and tablet width.

Requirements

No dependencies. Pure HTML, CSS and JavaScript.

Animated 404 Page – free Pure CSS error page template
Animated 404 Page · free Pure CSS error page template

More Error Pages

500 Server Error Page – free Bootstrap 5 error page template

500 Server Error Page

Dark Bootstrap 5 500 error page with a server rack illustration, retry button, status page link, copyable reference ID and service status list.

Simple 404 Page – free Tailwind CSS error page template

Simple 404 Page

Clean Tailwind CSS 404 error page with an animated unplugged-cable illustration, site search, helpful link cards and a go-back button.