A CSS page header is the topmost site region composing logo, nav, search, utility icons, CTA, and theme toggle — not a bare navbar. These 22 hand-coded patterns cover ⌘K command palette, SaaS app-shell with workspace switcher, docs-site with version dropdown, e-commerce with cart + wishlist, sticky CTA slide-in, article with reading progress, plus sticky, mega menu, hamburger overlay, glassmorphism, double-decker, and shrinking-on-scroll. Every scroll-driven demo uses animation-timeline: scroll() not a JS listener; every theme toggle is pure-CSS :has(:checked); every demo is scoped under .hd-NN and drops into React, Vue, Svelte, or Astro.

21 pure CSS1 light JSPublished 11 new designs · Updated on

Related8 CSS Navbar Designs25 CSS Footer Designs31 CSS Hero Sections15 CSS Navigation Menu Designs

Command Palette Trigger Header with ⌘K Shortcut — preview
01 / 22Light JSNEW

Command Palette Trigger Header with ⌘K Shortcut

The header pattern every developer tool ships in 2027: a muted search pill in the middle of the bar with a <kbd>⌘K</kbd> badge pinned to its right end. Clicking or tabbing to the pill opens a full command palette — recents, quick actions, help — that scales and fades in. The open/close is pure CSS state; the only script is a fourteen-line keyboard listener so the shortcut works from anywhere on the page.

Published

Docs Site Header with Version and Search — preview
02 / 22Pure CSSNEW

Docs Site Header with Version and Search

A documentation header that carries the three controls docs readers actually hunt for: the version switcher, the search field with its keyboard hint, and the Docs / API / Blog / GitHub row. The version dropdown opens on hover and on :focus-within, so it is fully keyboard operable without a line of script, and each release row shows its channel chip — Latest, LTS, Maintenance.

Published

SaaS App Shell Header with Workspace Switcher — preview
03 / 22Pure CSSNEW

SaaS App Shell Header with Workspace Switcher

The chrome that wraps a multi-tenant product: a workspace picker on the left showing the active tenant's avatar and a truncated name, section nav in the middle, and a right toolbar of search, notifications and account. Both menus open on hover and on :focus-within with no script, and the workspace list ends in a Create workspace row like every real switcher does.

Published

E-Commerce Header with Cart Wishlist Account — preview
04 / 22Pure CSSNEW

E-Commerce Header with Cart Wishlist Account

A storefront header with the utility cluster shoppers reach for: account, a wishlist heart carrying its count, and a cart pill showing the running total. Hovering Shop opens a category mega panel with three featured products; the count and total use tabular-nums so nothing shifts as the basket changes. Peach-to-lavender ground, condensed display type, accent-tinted shadow bloom.

Published

Marketing Header with Sticky CTA Slide-In — preview
05 / 22Pure CSSNEW

Marketing Header with Sticky CTA Slide-In

A landing-page header that stays quiet until it has earned the ask: logo, nav and a text link at rest, then a solid Start free trial button slides in from the right once the reader passes 240 px. It is driven entirely by animation-timeline: scroll(root) — no scroll listener, nothing to throttle — and where scroll-driven animation is unsupported the button is simply visible from the start.

Published

Article Header with Reading Progress Meter — preview
06 / 22Pure CSSNEW

Article Header with Reading Progress Meter

An editorial article header: section kicker, headline, byline with reading time, and a hairline progress meter that fills as the reader moves down the piece. The meter is a single element scaled with transform: scaleX() on a scroll(root) timeline, so it costs one composited layer instead of a scroll handler recalculating percentages on every frame.

Published

Minimal Centered Logo Editorial Header — preview
07 / 22Pure CSSNEW

Minimal Centered Logo Editorial Header

A masthead in the newspaper tradition: dateline and section on the left, a serif wordmark dead centre, subscribe and account on the right. The centring is structural rather than optical — a three-column grid with equal side tracks — so the wordmark stays exactly centred no matter how long the dateline or the buttons get.

Published

Transparent Over Hero Landing Page Header — preview
08 / 22Pure CSSNEW

Transparent Over Hero Landing Page Header

The landing-page classic done without a scroll listener: the header floats transparent over a full-bleed hero photograph, then solidifies into an opaque bar with dark ink as the reader passes 60 px. Nav text over the photo carries a drop shadow and a gradient scrim for contrast, and a checkbox-driven theme pill flips the whole surface with zero theme JavaScript.

Published

Header with Breadcrumb Integration — preview
09 / 22Pure CSSNEW

Header with Breadcrumb Integration

A two-tier header for deep pages: brand, section nav and utilities on the top row, then a breadcrumb trail on the row below with the page actions aligned to its right. The trail is a real &lt;nav aria-label="Breadcrumb"&gt; wrapping an ordered list, the last item carries aria-current="page", and separators are generated so they are never read aloud.

Published

Header with Notification Bell and User Menu — preview
10 / 22Pure CSSNEW

Header with Notification Bell and User Menu

The right-hand utility cluster, taken seriously: a notification bell with an unread pill that pulses once on arrival, a panel of recent notifications, and an avatar menu with profile, preferences and sign out. Both panels open on hover and on :focus-within, so the whole cluster is operable from the keyboard without a single line of script.

Published

Header with GitHub Star Count Pill — preview
11 / 22Pure CSSNEW

Header with GitHub Star Count Pill

The header every open-source project ships: wordmark, a short docs nav, and a star-count pill that links to the repository. The pill is outlined at rest and fills with GitHub black on :hover and :focus-visible, the count is set in tabular figures so it never nudges the layout, and the whole design is monochrome with a hard offset shadow instead of a soft one.

Published

Pure CSS Sticky Header with Scroll Timeline — preview
12 / 22Pure CSS

Pure CSS Sticky Header with Scroll Timeline

The reference sticky header, rebuilt: it starts fully transparent over the page and gains its surface, blur and gradient rim as the reader passes the first 80 px. Everything is position: sticky plus animation-timeline: scroll(root) — no listeners, no position: fixed, no layout shift — and browsers without scroll timelines get the solid bar from the first pixel.

PublishedUpdated

CSS Grid Mega Menu Header with Focus Within — preview
13 / 22Pure CSS

CSS Grid Mega Menu Header with Focus Within

A mega panel that is a genuine CSS Grid: a category column, a row of featured cards and a promo rail, laid out in three tracks and opened by :hover or :focus-within on the parent item. transition-behavior: allow-discrete means the closed panel truly leaves the flow, so its twenty links are not sitting in the tab order waiting to swallow keyboard focus.

PublishedUpdated

Flexbox Three Column Navbar Header — preview
14 / 22Pure CSS

Flexbox Three Column Navbar Header

The reference implementation: logo left, nav optically centred, actions right — and it stays centred even when the logo and the button are wildly different widths. The trick is giving the outer columns equal flex-basis and letting the nav claim the middle, rather than trusting space-between. Monochrome Swiss treatment, hairline rules, zero decoration.

PublishedUpdated

Full Screen Overlay Hamburger Header — preview
15 / 22Pure CSS

Full Screen Overlay Hamburger Header

A header that opens into a full-screen navigation overlay with no JavaScript: a visually hidden checkbox, a label styled as the hamburger, and :has(:checked) on the root. The bars morph into an X with a spring curve, menu items stagger in on animation-delay, and the closed overlay is hidden with visibility so its links never sit in the tab order.

PublishedUpdated

Glassmorphism Transparent Header Bar — preview
16 / 22Pure CSS

Glassmorphism Transparent Header Bar

A full header surface in glass: backdrop-filter: blur(20px) saturate(180%) over an ambient aurora background, with a thin inner-highlight stroke along the top edge that sells the material. The solid rgba() fallback is declared first, so browsers without backdrop-filter get an opaque bar that still meets contrast rather than unreadable text over a gradient.

PublishedUpdated

Header with Announcement Bar Dismissible — preview
17 / 22Pure CSS

Header with Announcement Bar Dismissible

A promo bar above the header that collapses to nothing when dismissed — no script, no display:none jump. The close button is a label for a hidden checkbox, and the bar animates from grid-template-rows: 1fr to 0fr, which is the modern way to transition to intrinsic zero height. Warm sepia surface with soft neumorphic relief.

PublishedUpdated

Two Tier Double Decker Enterprise Header — preview
18 / 22Pure CSS

Two Tier Double Decker Enterprise Header

The double-decker enterprise header: a dense utility strip on top for support, docs, region, currency and language, then the primary bar underneath with logo, main nav and the demo CTA. Ultra-compact spacing, zero border radius and sharp hairlines — the vocabulary banks, healthcare portals and B2B platforms actually use.

PublishedUpdated

Animated Link Hover Effects Header — preview
19 / 22Pure CSS

Animated Link Hover Effects Header

Five nav-link hover treatments in one header, side by side, so you can compare them in context rather than in isolation: a scaleX underline, a clip-up fill, a gradient sweep, a dual-layer label swap and a bracket reveal. Every one runs on transform and opacity only, and every one is wired to :focus-visible as well as :hover.

PublishedUpdated

Vertical Sidebar App Shell Header — preview
20 / 22Pure CSS

Vertical Sidebar App Shell Header

When the header is vertical: a sidebar carrying the logo, grouped navigation and a user footer, with the main region getting a slim top bar for breadcrumb and page actions. The shell is one CSS Grid, the sidebar collapses to an icon rail on a pure-CSS toggle, and both regions scroll independently without breaking sticky positioning.

PublishedUpdated

Multi Level Dropdown Menu Header — preview
21 / 22Pure CSS

Multi Level Dropdown Menu Header

Three levels of nested navigation, opened by hover and by :focus-within, with each level flying out to the side of its parent row. Sub-panels flip to the opposite side near the viewport edge, every level is a real role="menu" with aria-haspopup triggers, and the whole thing is keyboard-walkable with <kbd>Tab</kbd> alone. Ink-and-sand minimal luxury, no shadows.

PublishedUpdated

Shrinking Header on Scroll Animation Timeline — preview
22 / 22Pure CSS

Shrinking Header on Scroll Animation Timeline

The header condenses as you read: 5 rem tall at rest, 3.25 rem once you pass 200 px, with the wordmark scaling down and the shadow deepening on the same timeline. Driven by animation-timeline: scroll(root), so there is no scroll handler and no requestAnimationFrame loop — and without scroll-timeline support the header simply stays at a fixed height.

PublishedUpdated

FAQ

Frequently asked questions

How do I build a CSS sticky header that solidifies on scroll without JavaScript?
The classic pattern uses window.addEventListener('scroll', …) in JavaScript to toggle a class on the header when scroll position passes a threshold. That approach still works but costs INP (Interaction to Next Paint) on Core Web Vitals — every scroll event runs the handler on the main thread, which lags on mid-tier mobile. The 2026 pattern uses position: sticky plus a scroll-linked CSS animation defined with @keyframes and animation-timeline: scroll(root) that interpolates background opacity and backdrop-filter from 0 → 1 as the page scrolls past the first 80px. Zero JavaScript, zero scroll listeners, zero CWV impact. Baseline in Chromium 115+ / Safari 18+ / Firefox 130+. Demo 12 is the reference implementation with an @supports (animation-timeline: scroll()) gate and a solid-always fallback for older browsers. Most tutorials still teach the JavaScript pattern because they predate the spec — a real gap developers land on this collection to fill.
How do I add a Cmd+K command palette to my site header?
The visible layer is pure CSS — the trigger is a search pill in the middle of the header showing 'Search…' and a ⌘K badge, styled as a real search affordance rather than a decoration. Clicking or focusing the pill opens a modal command palette overlay implemented as a native <dialog> element opened via <details> disclosure. The overlay uses backdrop-filter: blur() on the scrim, animates in with a scale-and-fade, and closes when the backdrop is clicked or Escape is pressed (both handled natively by <dialog>). The keyboard shortcut is the only JavaScript — under 15 lines of document.addEventListener('keydown', ...) that checks for event.key === 'k' && (event.metaKey || event.ctrlKey) and calls dialog.showModal(). event.preventDefault() on the match to stop the browser's default 'find in page' shortcut. Linear, Vercel, Raycast, GitHub, Notion, and Cursor all ship this pattern; demo 01 is the copy-paste version. Accessibility: <dialog> handles focus trap and focus return natively when opened with showModal().
How do I stop position:sticky from breaking silently in production?
Position sticky has three failure modes tutorials rarely mention. First, an ancestor with overflow: hidden (or any overflow value other than visible) creates a scroll container that becomes the sticky's containing block — the header sticks to the ancestor's edge, not the viewport, which usually reads as 'sticky just isn't working'. Fix by moving the sticky element out of the overflow-clipped ancestor, or by promoting the ancestor to overflow: clip where possible (clip creates a paint boundary without a scroll container). Second, the sticky element and its siblings must live in the same containing block — a header inside a wrapper that has contain: layout or transform will detach from the page scroll and stick to its wrapper. Third, position: fixed is NOT a substitute — fixed removes the header from document flow, causing layout-shift (CLS) on load and breaking scroll-timeline animations that depend on the header being part of the flow. Every demo in this collection uses position: sticky; top: 0 for that reason. If sticky misbehaves, run document.querySelectorAll('*').forEach(el => { const cs = getComputedStyle(el); if (cs.overflow !== 'visible' && cs.overflow !== '') console.log(el, cs.overflow); }) in devtools to find the offending ancestor.
What's the correct pattern for a keyboard-accessible mega menu?
Most 'CSS mega menu' tutorials use :hover alone, which fails for keyboard and touch users. The correct pattern uses :focus-within on the parent <li>: the menu panel opens when ANY descendant element receives focus, so tabbing into the trigger button opens the panel and tabbing through the items keeps it open until focus leaves. Pair with :hover on the same parent for pointer users. Every trigger is a real <button> (not a <div> or <a href='#'>) with aria-haspopup='menu' and aria-expanded reflecting state. The panel wrapper is role='menu' and each item is role='menuitem' — screen readers announce 'menu, 4 items' when the panel opens. Use transition-behavior: allow-discrete (Baseline 2024) so visibility transitions cleanly instead of the panel remaining hit-testable while invisible. Demo 13 is the CSS Grid mega menu reference, demo 21 is the 3-level nested dropdown, demo 10 is the notification-bell + user-menu combined pattern — all keyboard-navigable without JavaScript. This matters on real e-commerce and docs sites where 30-40% of navigation traffic comes from keyboard-heavy workflows (autocomplete, screen reader, mouse-lost, external keyboards).
How do I build a pure-CSS light/dark theme toggle in the header that works on any OS preference?
The pattern is a visually-hidden <input type='checkbox'> plus a <label> styled as the sun/moon toggle, plus :has(:checked) on the header root that rewrites CSS custom properties. Every colour reads from the properties, so one :checked flips the whole palette. Zero JavaScript. The subtle bug every implementation hits: on a visitor whose OS preference matches your default (light-OS visitor on a light-default site), the toggle appears to do nothing on the first click because both the OS-driven rule (.hd-NN:not([data-theme='dark']):not(:has(:checked)) inside @media (prefers-color-scheme: light)) and the :has(:checked) rule land on the same light values. Only the second click flips anything. Fix by adding a nested flip-back rule inside the @media (prefers-color-scheme: light) block: .hd-NN:has(:checked){ …dark-base values… } that restores the opposite base when the checkbox is checked on a light-OS visitor. Restore EVERY custom property from the dark base, not just --bg. Demos 08, 10, and 11 ship this pattern verbatim — the nested-media flip-back rule is the single most-missed accessibility fix in dark-mode toggles across the ecosystem.
How do I meet WCAG 2.2 AA for header navigation, focus rings, and target sizes?
Six requirements from AA that every header in this collection meets. First, SC 2.4.1 (Bypass Blocks) — a visually-hidden skip-to-content link at the top of every header that becomes visible on :focus-visible. Second, SC 2.4.13 (Focus Appearance, added in WCAG 2.2) — every focus indicator is at least 2 CSS pixels thick and reaches 3:1 contrast against adjacent colours. Dark-mode headers use a distinct --focus-ring token calibrated for the dark surface (bright cyan tends to work — oklch(83% 0.13 200)), not the primary accent. Third, SC 2.5.8 (Target Size Minimum, WCAG 2.2) — every icon-only button hits at least 24×24 CSS pixels; interactive controls in dense headers hit 44×44 (Level AAA). Fourth, SC 4.1.2 (Name, Role, Value) — every <nav> carries aria-label naming its role (Main, Breadcrumb, Utility, Footer), every icon-only button carries aria-label, every dropdown trigger carries aria-haspopup='menu' and aria-expanded. Fifth, SC 1.4.11 (Non-text Contrast) — 3:1 for the borders around search pills, badges, and any UI component that carries meaning. Sixth, SC 2.4.7 (Focus Visible) — never outline: none without an equivalent replacement (a box-shadow ring or outline that meets 2.4.13). Compliance matters especially for HIPAA, education, government, and enterprise SaaS traffic — those verticals audit their vendors on accessibility before purchase.
How is this different from the shipped navbar and mobile-navigation collections?
Nine adjacent collections on codefronts cover different scopes. css-navbars (8 demos) ships bare navigation bars — logo + links only. css-header-designs (this collection, 22 demos) ships full-page-header compositions — logo + primary nav + utility cluster + search + CTA + theme all together as one region. css-sticky-navigation (25 demos) owns the pure-CSS position: sticky mechanism — every demo here uses position: sticky because a header requires it, but the design lane is composition, not sticky behavior. css-responsive-navbar (20 demos) owns breakpoint-collapse patterns. css-hamburger-menus (28 demos) owns the hamburger widget itself. css-mobile-navigation (16 demos) owns mobile-first patterns (bottom tab, drawer, radial). css-mega-menus (6 demos) owns standalone mega panels. css-sidebar-navigation (10 demos) owns vertical navigation. css-glassmorphic-navbars (11) and css-liquid-glass-navbars (24) own glass NAVBARS specifically. Every demo in this collection is the composed header region — the topmost site strip where a real product ships its logo, nav, search, cart, workspace switcher, and utility icons together. If you need a bare navbar, use css-navbars; if you need the full header, this collection is the one.
How portable are these header patterns across Tailwind, React, Vue, Svelte, and Astro?
Every demo is framework-agnostic vanilla HTML + CSS + optional under-15-line JS, scoped under a unique .hd-NN root that drops into any framework without leaking. Tailwind v3 users translate the CSS to @apply inside @layer components; Tailwind v4 uses the CSS-first config so --font-display, --surface, --ink tokens can be declared in @theme and consumed by both the utility variants and the demo's own rules. React and Next.js apps wrap the demo as a <Header /> component; the theme-toggle demos work with any theme-provider that writes data-theme on document.documentElement (the demo CSS reads the attribute regardless of who sets it). Vue 3 users bind :data-theme="theme" on the layout root and useDark() from VueUse writes it. Svelte does it with bind:data-theme. Astro islands (client:visible) work with the pure-CSS demos as-is; hydrate a small island around demo 01 for the ⌘K keyboard listener. SolidJS, Qwik, and Angular signals all map to the same [data-theme] attribute pattern. The scroll-timeline demos (01, 05, 06, 08, 12, 22) use animation-timeline: scroll(root) which needs no framework code at all — the animation lives entirely in CSS and works identically across every stack.

Related collections

15 CSS Aspect Ratio Demos preview

15 CSS Aspect Ratio Demos

15 hand-coded CSS aspect-ratio demos for video embeds, product galleries, IAB ad slots, native dialogs, and CLS-safe placeholders: 16:9 iframe YouTube embed with click-to-load facade + up-next rail, 21:9 full-screen hero video with min-height/max-height:100svh guardrails + Ken Burns drift, 1:1 Instagram-style square grid with 2×2 feature tile, 4:3 magazine card image cover, 9:16 vertical stories rail (TikTok/Reels/Shorts pattern) with scroll-snap + segment bars, 4:5 apparel product image gallery with radio-driven state + 1:1 thumbnails, 1:1 zoom thumbnail carousel with pointer-tracked --zx/--zy magnifier, prevent-layout-shift placeholder with live PerformanceObserver CLS meter (before/after side-by-side lab), dynamic content fallback with three policies (bend/strict/auto) via :has() toggle, IAB ad banner slots (728×90 leaderboard, 300×250 medium rectangle, 300×600 half-page, 320×50 mobile) with skeletons + container-query mobile swap, responsive modal dialog sized min(92vw, 88svh×16/9, 1080px) with @starting-style animation, responsive OpenStreetMap iframe wrapper with 16:9 → 1:1 container-query narrow swap, media query orientation live HUD + resize:both container-ratio playground, object-fit logo cloud with contain/cover/fill switcher via :has(), and side-by-side padding-top hack (height:0 + padding-top:56.25%) → modern aspect-ratio migration comparison with live ratio picker. 11 truly Pure CSS + 4 with a tiny optional vanilla JS snippet (facade swap, pointer magnifier, CLS meter, native dialog). Every demo is scoped under a unique .car-NN prefix so it drops into any project without CSS collisions, ships prefers-reduced-motion guards, and is framework-agnostic (works as-is in React, Vue, Svelte, Astro, Next.js, Remix, or plain HTML).

6 CSS Bento Grid Layouts preview

6 CSS Bento Grid Layouts

6 production CSS bento grid layouts with 12 hand-coded designs — Apple-style product showcase, SaaS feature value-prop matrix, analytics dashboard overview, creative portfolio, e-commerce category hub, and link-in-bio social hub. Each topic ships 2 sub-variants side-by-side so visitors see both a keynote aesthetic and a paper-doc variant at once. Container queries, CSS Grid, zero dependencies, copy-paste ready.

20 CSS Blog Layouts preview

20 CSS Blog Layouts

20 hand-coded CSS blog and editorial layouts for magazine homepages, news sites, personal archives, newsletter back-issues, recipe and podcast blogs, developer tutorials, and long-form journalism. Covers a magazine homepage with hero plus editor-picks rail, a news homepage with breaking-news ticker, blog archives with sticky year separators, Substack-style issue-numbered archives, recipe card grids with prep-time badges, podcast episode lists with waveforms, long-form articles with scroll-driven reading progress, drop caps and floated pull quotes via first-letter, Medium-style 65ch centred reader layouts, dev tutorials with a sticky code panel beside prose, interview transcripts with alternating speakers, case-study pages with stat counters, video blogs with an episode rail, full-bleed photo essays, news articles with sticky related-stories sidebars, documentation pages with prev/next chapter nav, a standalone blog post card, a scroll-snap category filter bar, an inline newsletter callout that breaks out of the prose column, and a horizontal featured-post rail. 12 are pure CSS with zero JavaScript. Every layout is scoped under a .bl-NN prefix for no-collision pasting, guards prefers-reduced-motion, and ports unchanged to React, Vue, Svelte, Astro, Next.js and Tailwind.

Search CodeFronts

Loading…