Examples
Default
Basic header without additional styling.
<header> <h2>Page Title</h2> <p>A brief description of the page content.</p></header>
.site
Full-width site header with flexbox layout.
<header class="site"> <strong>Brand</strong> <nav class="horizontal pills" aria-label="Site navigation"> <ul> <li><a href="#">Home</a></li> <li><a href="#">Products</a></li> <li><a href="#">About</a></li> <li><a href="#">Contact</a></li> </ul> </nav></header>
.page
Page header with bottom border and spacing.
<header class="page"> <h1>Documentation</h1> <p>Learn how to use Vanilla Breeze in your projects.</p></header><p>Page content begins here...</p>
.card
Card header with bottom border.
<layout-card> <header class="card"> <h2>Card Title</h2> </header> <p>Card content goes here...</p></layout-card>
Sticky
Add data-sticky to pin the header to the top of the viewport during scroll. See the data-sticky attribute page for full details and recipes.
Put the sticky header directly in <body>. Sticky positioning only holds inside the header's parent, and a body-level header is also what gets anchor protection: html:has(> body > header[data-sticky]) sets scroll-padding-block-start so in-page links land below the header instead of under it. The padding uses --sticky-offset (measured by the coordinated <html data-sticky> system), falling back to --header-sticky-size, which defaults to the .site header's reserved height. Set --header-sticky-size on :root if your header is taller.
<body> <header data-sticky class="site"> <strong>Sticky Header</strong> <nav class="horizontal pills" aria-label="Main"> <ul> <li><a href="#line-1">Line 1</a></li> <li><a href="#line-10">Line 10</a></li> </ul> </nav> </header> <main>...</main></body>
Auto-hiding (data-scroll-hide)
Add data-scroll-hide to make the header sticky, slide it away as the reader scrolls down, and bring it back once they scroll up about 40px. The upward distance adds up across small scroll steps, so slow trackpad or keyboard scrolling reveals it too. A small script loads automatically when the attribute is present. It sets data-hidden while the header is away.
If focus moves into a hidden header, for example when tabbing back to the navigation, the header slides back in, so a focused link is never offscreen. With prefers-reduced-motion: reduce the header still hides and returns, but without the slide.
<header data-scroll-hide class="site"> <strong>Auto-hiding Header</strong> <nav class="horizontal pills" aria-label="Main"> <ul> <li><a href="#line-1">Line 1</a></li> <li><a href="#line-10">Line 10</a></li> </ul> </nav></header>
.transparent
Positions the header absolutely over the top of the page with no background, for headers that sit on a hero image or colour band. Give the hero enough top padding to clear the header, and check the header text still has enough contrast against whatever is behind it.
<header class="site transparent"> <strong>Brand</strong> <nav class="horizontal pills" aria-label="Main">...</nav></header><main> <section class="hero"> <h1>Header over a hero</h1> </section></main>
.centered
Centered header for landing pages.
<header class="centered"> <h1>Welcome to Our Site</h1> <p>Building the future of web development, one component at a time.</p></header>
.compact
Compact header with reduced padding and smaller text.
<header class="compact site"> <strong>Brand</strong> <nav class="horizontal minimal" aria-label="Main"> <ul> <li><a href="#">Home</a></li> <li><a href="#">Docs</a></li> <li><a href="#">API</a></li> </ul> </nav></header>