A full-screen 404 page built with Tailwind CSS that places the "page not found" message over a dramatic photo of mountain peaks above a sea of clouds. An outlined "404", a short on-theme message, a primary "Back to home" button, a "Previous page" button and a row of popular links turn a dead end into a branded moment for travel, outdoor and portfolio sites.
How it works
The root is main.nfp-page, a min-h-screen flex column with isolate and overflow-hidden. Two absolutely positioned layers sit behind the content: .nfp-photo, which loads the background image in style.css with background-size: cover, and a bg-gradient-to-r overlay that is darkest on the left where the text lives. On phones the overlay stays darker across the whole width so the text keeps its contrast over the bright sunset.
The content column holds a small header with a logo link, the .nfp-code "404" (transparent fill with -webkit-text-stroke, so the photo shows through the digits), an error pill, the #nfp-title heading, the buttons and a nav with popular links. The nfp-drift keyframes zoom the photo very slowly for a subtle sense of depth.
The script only handles [data-nfp-back]. The button starts with hidden and is shown when history.length or document.referrer indicate a previous page; a click calls history.back() and falls back to the [data-nfp-home] link if the page did not change. Without JavaScript users simply get the home link.
Customization
background-imagein.nfp-photo(style.css): use your own photo. The current image comes from Unsplash and should be replaced with an image you own; adjustbackground-positionto keep the focal point visible.aria-labelon.nfp-photo: update the description to match your new photo, or replacerole="img"witharia-hidden="true"if it is purely decorative.from-slate-950/90 via-slate-950/70 to-slate-950/40(and thesm:via-slate-950/60 sm:to-slate-950/10desktop values) on the overlay: raise the opacities for brighter photos or usebg-gradient-to-tfor a bottom-up fade.bg-orange-300on the home button andtext-orange-200on the pill: switch toskyoremeraldto match your brand.-webkit-text-strokein.nfp-code: thicken the outline, or remove the rule for solid white digits.nfp-drift 24sinstyle.css: slow down the zoom or remove the animation entirely.- The links in the
navlabelled "Popular pages": point them to your most visited sections.
Use cases
- Any website: a full-screen photo and outlined 404 make a missing page look intentional
- Content sites: home and back buttons help visitors recover quickly
- Ecommerce stores: quick links point lost visitors to popular pages
- Travel and outdoor brands: a mountain photo with a dark overlay fits the brand mood
Accessibility
The page is a single main labelled by the h1. The decorative "404" is aria-hidden because the pill and heading already state the error. The photo layer has role="img" with a short description, and decorative icons are aria-hidden. Every link and button shows a visible focus-visible ring, the "Previous page" button is only rendered when it can work, and the background zoom stops under prefers-reduced-motion.
Usage notes
This is a full-page template: serve it with an HTTP 404 status from your server, and use absolute URLs for links because the 404 page can appear at any path.