Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan Now×
Skip to content
CSS

Custom Website Header Examples and How to Build Them

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A strong website header gives visitors a reliable way to identify the site, reach important sections, search, and complete a primary action. Build it with a semantic <header>, a linked logo or site name, one or more clearly labelled <nav> regions, native links and buttons, and a responsive layout that changes when the available width changes. The examples below show practical patterns for portfolios, publications, stores, and institutions, followed by a complete HTML/CSS implementation you can adapt.

What a website header should contain

The HTML <header> element groups introductory content and navigational aids. For a site-wide header that is not nested inside another sectioning element, it represents the banner landmark. It is not a heading level and does not replace an <h1> in the page content.

Most global headers combine a home destination with the controls visitors use repeatedly:

  • Identity: a logo or text wordmark linked to the home page.
  • Primary navigation: links to the sections most visitors need.
  • Search: useful for publications, stores, documentation, and other large collections.
  • One prominent action: such as “Get started,” “Contact,” or “Donate,” only when it represents a real priority.
  • Utility links: account, language, help, or location controls when they serve a distinct task.

Use <nav> for link groups instead of making the entire header one clickable container. If there are multiple navigation regions, give each an accessible name, for example “Main navigation” and “Language options.”

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Four header examples to adapt

Minimal brand bar

A small organization or portfolio usually needs a linked wordmark, three to five primary links, and one action. Keep the hierarchy obvious: identity first, navigation second, action last. Do not add a search field or account menu merely because other sites have one.

#1 Best Overall
Sale
HTML and CSS: Design and Build Websites
  • HTML CSS Design and Build Web Sites
  • Comes with secure packaging
  • It can be a gift option

Editorial header

A publication benefits from a recognizable masthead, section navigation, and search. On narrow screens, retain the masthead and a menu control while moving the full section list into an expandable panel. The sections should reflect the information architecture, not every category in the database.

Commerce header

An online store commonly combines the store identity, product-category navigation, search, and account or cart utilities. Organize categories so the header does not become a wall of controls. A visible cart count should remain understandable to screen-reader users and should not be the only way to reach the cart.

Utility or institutional header

Government, education, and nonprofit sites often need a primary navigation plus secondary links such as language options, accessibility information, or audience-specific services. Separate these groups into named navigation landmarks. A language selector belongs in its own group rather than being mixed into the main site sections.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Semantic HTML foundation

Start with document order that makes sense without CSS. Put the skip link first, then the site header, then the main content. Use a real link for a destination and a real button for an action such as opening a menu. Avoid assigning click handlers to generic <div> elements.

<body>
  <a class="skip-link" href="#main-content">Skip to main content</a>

  <header class="site-header">
    <div class="header-inner">
      <a class="brand" href="/" aria-label="Acme home">
        <span class="brand-mark" aria-hidden="true">A</span>
        <span>Acme</span>
      </a>

      <button class="menu-toggle" type="button"
              aria-expanded="false" aria-controls="main-menu">
        Menu
      </button>

      <nav id="main-menu" class="main-nav" aria-label="Main navigation">
        <a href="/work">Work</a>
        <a href="/about">About</a>
        <a href="/resources">Resources</a>
        <a class="header-action" href="/contact">Contact</a>
      </nav>
    </div>
  </header>

  <main id="main-content">
    <h1>Selected work</h1>
    <!-- page content -->
  </main>
</body>

The aria-label distinguishes this navigation if the page later gains another navigation region. The logo link has an explicit accessible name, while the decorative mark is hidden from assistive technology.

Responsive CSS that reflows instead of forcing a device breakpoint

Use flexbox or grid for alignment and let the layout respond to the space the actual content needs. The breakpoint below is only an example; choose a point where your links no longer fit comfortably, then test around it.

:root {
  --ink: #17202a;
  --muted: #5b6673;
  --line: #d9dee5;
  --surface: #ffffff;
  --accent: #0b63ce;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--ink);
  font: 1rem/1.5 system-ui, sans-serif;
}
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.header-inner {
  width: min(100% - 2rem, 72rem);
  min-height: 4.5rem;
  margin-inline: auto;
  display: flex;
  align-items: center;
  gap: 2rem;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  color: inherit;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 2rem;
  aspect-ratio: 1;
  border-radius: .4rem;
  background: var(--accent);
  color: white;
}
.main-nav {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: .25rem;
}
.main-nav a {
  padding: .6rem .75rem;
  color: inherit;
  border-radius: .35rem;
  text-decoration: none;
}
.main-nav a:hover,
.main-nav a:focus-visible { background: #eef4fb; }
.header-action { background: var(--accent); color: white !important; }
.menu-toggle { display: none; }
.skip-link {
  position: absolute;
  left: .75rem;
  top: -4rem;
  z-index: 10;
  padding: .6rem .8rem;
  background: var(--ink);
  color: white;
}
.skip-link:focus { top: .75rem; }
:focus-visible { outline: 3px solid #f3a712; outline-offset: 3px; }

@media (max-width: 48rem) {
  .header-inner { flex-wrap: wrap; padding-block: .75rem; }
  .menu-toggle {
    display: inline-block;
    margin-left: auto;
    padding: .55rem .75rem;
    border: 1px solid var(--line);
    border-radius: .35rem;
    background: white;
    color: inherit;
    font: inherit;
  }
  .main-nav {
    display: none;
    flex-basis: 100%;
    margin-left: 0;
    padding-bottom: .5rem;
    flex-direction: column;
    align-items: stretch;
  }
  .main-nav[data-open="true"] { display: flex; }
}

Do not hide links solely because a screen is narrow. The menu button should expose the same destinations, preserve a visible focus indicator, and update its expanded state.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Making the mobile menu work

A small script can toggle the navigation while keeping the button state synchronized. The menu is closed by default in the markup, so users without JavaScript still receive the navigation links if you add a no-script fallback or choose a CSS-only disclosure pattern.

const toggle = document.querySelector('.menu-toggle');
const menu = document.querySelector('#main-menu');

toggle.addEventListener('click', () => {
  const open = toggle.getAttribute('aria-expanded') === 'true';
  toggle.setAttribute('aria-expanded', String(!open));
  menu.dataset.open = String(!open);
});

For a production menu, also decide what happens when a visitor presses Escape, clicks outside the menu, or activates a link. Return focus to the menu button after closing, and avoid trapping focus unless the control is a true modal dialog.

Ordering, accessibility, and interaction checks

  • Keep DOM order aligned with the intended reading and keyboard order. Do not use CSS ordering to put the call-to-action first visually while it remains last in the interaction sequence without a clear reason.
  • Place a skip link near the start of the document so keyboard users can bypass repeated navigation.
  • Use descriptive link text; “Services” is preferable to several links labelled “Learn more.”
  • Ensure every interactive element has a visible focus state and a usable hit area.
  • Give separate navigation landmarks meaningful names when more than one appears.
  • Check contrast, zoom, text wrapping, and keyboard operation at narrow and wide widths.
  • Test with a screen reader or accessibility tree to confirm that the logo, menu button, expanded state, and navigation names are announced as intended.

How to choose between header variants

Decision axis Questions to ask Practical implication
Content priority How many links are genuinely used? Reduce low-value links; reserve space for identity and the primary task.
Information architecture Are there separate audiences, languages, or utilities? Split distinct groups into named navigation regions.
Viewport behavior When does the content stop fitting? Reflow or simplify at the point of pressure, not at a device label chosen in advance.
Keyboard and assistive technology Can every destination be reached and understood without a mouse? Use native controls, logical order, labels, focus styles, and a skip link.
Brand fit Does type, spacing, color, and logo treatment match the site? Apply visual identity after the semantic structure is sound.

Common implementation failures and fixes

The whole header is clickable

Symptom: users cannot tell which destination they will activate, or keyboard focus lands on a large ambiguous region. Fix: keep the brand as one home link and expose each navigation destination as its own link.

The mobile links disappear permanently

Symptom: CSS hides the navigation and the toggle does not reveal it. Fix: verify that the script loads after the markup, the selector IDs match, and the button changes both aria-expanded and the visible state.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Visual order differs from reading order

Symptom: keyboard users encounter controls in an unexpected sequence. Fix: reorder the markup, then use CSS only for presentational alignment.

Multiple nav landmarks have identical names

Symptom: assistive-technology users cannot distinguish main links from language or utility links. Fix: provide specific labels such as “Main navigation,” “Language options,” and “Account navigation.”

The header becomes unusable at intermediate widths

Symptom: links wrap into a second row, overlap, or push the action off-screen. Fix: resize the viewport gradually, reduce unnecessary spacing, allow a deliberate wrap, or switch to the compact menu when the content no longer fits.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

If your goal is to capture a rendered header for documentation, visual QA, or a design review, ScreenshotNeo returns a screenshot from one request. It accepts the cookie or consent banner like a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each cleanup step can be disabled. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and the response identifies the result with X-Page-Verdict and X-Billed headers. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

cURL (see the ScreenshotNeo API documentation):

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

Python:

import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)

Node.js:

const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);

You can request PNG, JPEG, WebP, or PDF and control options such as full-page capture with lazy images loaded, a CSS selector for one element, dark mode, device presets or a custom viewport, retina scale, custom CSS or JavaScript, a pre-capture click, hidden selectors, selector/delay/network-idle waits, blocked requests or resource types, headers, cookies, user agent, authorization, timezone, geolocation, transparent backgrounds, resizing, a chosen cache TTL, signed image links, asynchronous jobs with signed webhooks, bulk capture of up to 100 URLs per call, usage data, and an OpenAPI specification. PDF options include paper size, margins, landscape mode, and page ranges. Existing parameter names used by other screenshot APIs also work.

The Free plan includes 1,000 screenshots each month with no card. Paid plans start at $5 for 3,000 shots; every feature is available on every plan, and annual billing provides two months free. Sign up for the free ScreenshotNeo plan to capture your header without configuring a browser.

Final pre-launch checklist

  • The brand link reaches the correct home destination.
  • Primary links reflect real visitor tasks and have clear text.
  • Each additional navigation region has a useful accessible name.
  • The skip link moves focus to the main content.
  • The compact layout works at intermediate widths, not just one phone preset.
  • The menu button exposes its state and remains keyboard operable.
  • Focus is visible, contrast is sufficient, and no control is clipped at high zoom.
  • Header changes do not shift content unexpectedly or obscure the page heading.

Frequently Asked Questions

Is a site-wide header the same thing as an h1?

No. A site-wide header groups identity and navigation. The page’s heading hierarchy still needs an appropriate h1 in the main content.

Should every website header include a search box?

No. Add search when it supports a frequent task, such as finding articles, products, or documentation. Omit it when the site is small enough to browse directly.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

How many links should fit in a desktop header?

There is no universal number. Keep the links that represent the site’s highest-priority tasks and switch to a compact arrangement when the actual content no longer fits comfortably.

Can I use CSS grid instead of flexbox?

Yes. Both are suitable layout tools. Choose the one that makes alignment and responsive reflow easiest to maintain while preserving logical document order.

Quick Recap

SaleBestseller No. 1
HTML and CSS: Design and Build Websites
HTML and CSS: Design and Build Websites
HTML CSS Design and Build Web Sites; Comes with secure packaging; It can be a gift option
$14.18
SaleBestseller No. 2
SaleBestseller No. 4

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Read next

Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.