Codectionary / Developer documentation / HTML

<header>

The <header> element represents introductory content for its nearest ancestor sectioning element, typically containing a logo, site title, navigation, or search form. A page can have multiple <header> elements — one for the page itself, and others for individual <article> or <section> elements. It has no default visual styling of its own.

Syntax

<header>
  <h1>Site Title</h1>
  <nav><!-- navigation links --></nav>
</header>

Examples

Page Header

A typical site-wide header with logo and navigation.

<header>
  <h1>Codectionary</h1>
  <nav>
    <a href="/docs">Docs</a>
    <a href="/playground">Playground</a>
  </nav>
</header>

Article Header

A header scoped to a single article, containing its title and metadata.

<article>
  <header>
    <h2>Understanding CSS Grid</h2>
    <p>Published on March 3, 2026 by Jane Doe</p>
  </header>
  <p>CSS Grid is a two-dimensional layout system...</p>
</article>

Styled Header

A page header with basic styling.

<header style="display: flex; justify-content: space-between; align-items: center; padding: 16px 24px; background: #1f2937; color: white;">
  <strong>Codectionary</strong>
  <nav style="display: flex; gap: 16px;">
    <a href="#" style="color: white;">Home</a>
    <a href="#" style="color: white;">About</a>
  </nav>
</header>

Best practices

  • Use <header> for introductory content, not as a generic styling wrapper — that is what <div> is for
  • A page can have more than one <header>, scoped to different sections or articles
  • <header> should not be nested inside <footer>, <address>, or another <header>
  • Combine with <nav> for the primary site navigation rather than placing links loose inside <header>

Browser compatibility

Support applies to the named feature, not every attribute or behaviour in this article. Versions refer to browsers, not operating systems.

<header>

Desktop

Chrome
Supported
From 5
Firefox
Supported
From 4
Safari
Supported
From 5
Edge
Supported
From 12
Opera
Supported
From 11.1

Mobile

Safari on iOS
Supported
From 4.2
Chrome for Android
Supported
From 18
Firefox for Android
Supported
From 4
Samsung Internet
Supported
From 1.0

MDN BCD record for this feature · MDN reference

Support history and limitations

Chrome

  • From 5

Firefox

  • From 4

Safari

  • From 5

Edge

  • From 12

Opera

  • From 11.1

Safari on iOS

  • From 4.2

Chrome for Android

  • From 18

Firefox for Android

  • From 4

Samsung Internet

  • From 1.0

MDN BCD 8.1.5 · Dataset built 2026-10-08 · Mapping reviewed 2026-10-21. These dates are not individual browser-test or claim-verification dates. Unknown means the data does not establish support.

HTML Living Standard

Specifications & further reading