<header>

An introduction to a page or section: logo, title, navigation, author info.

Display
block
Closing tag
Required
Permitted content
Flow content without <header> and <footer> elements
On this page

Example

#
HTML
<header>
  <a href="/">CodeWorlds</a>
  <nav aria-label="Main">
    <a href="/courses">Courses</a> ·
    <a href="/docs">Docs</a> ·
    <a href="/collections">Collections</a>
  </nav>
</header>
Preview

Definition and usage

#

The <header> element holds introductory content. At the whole-page level, that’s usually a logo, the site name, and the main navigation. Inside an <article> or <section>, it’s a title, a publish date, an author, or a short lead.

A single page can have multiple <header> elements, one for each section or article. It can’t, however, sit inside a <footer>, an <address>, or another <header>.

A page header placed directly inside <body> is recognized by assistive technology as a "banner" landmark. The same element nested inside an article no longer plays that role.

Syntax

#
Syntax
<header>
  …
</header>

Attributes

#

This element has no attributes of its own. It supports the global attributes, such as class, id and hidden.

More examples

#
Article header
HTML
<article>
  <header>
    <h2>Flexbox in 10 minutes</h2>
    <p>Author: Marta Nowak · <time datetime="2026-05-02">May 2, 2026</time></p>
  </header>
  <p>Flexbox lays out elements along one dimension: in a row or in a column.</p>
</article>
Preview

Default CSS

#

Most browsers display this element with these default styles:

CSS
header {
  display: block;
}

Browser support

#

Widely available

Works in all modern browsers, phones included. You can use it without worry.

  • Chrome
  • Edge
  • Firefox
  • Safari

Good practices

#
  • <header> isn’t the same as <head>. The latter holds metadata and isn’t displayed on the page.
  • A header alone isn’t enough as a section’s title. You still need an <h1>-<h6> inside it.

Related entries

#

Spotted a mistake or missing an example? Write to us.