Skip to main content
HTML Validation

The element “header” must not appear as a descendant of the “header” element.

About This HTML Issue

The <header> element has a specific content model restriction: it must not contain <header>, <footer>, or <main> elements as descendants. This means that not only direct children but any nested <header> — even one buried several levels deep inside other elements — will trigger this validation error.

This restriction exists because each <header> is supposed to introduce its surrounding sectioning content (like <article>, <section>, <nav>, or the <body> itself). If one <header> contains another, it becomes unclear which section each header is introducing. This ambiguity hurts accessibility, as screen readers rely on these landmarks to help users navigate the page structure. Assistive technologies may announce nested headers incorrectly or confuse users about where sections begin and end.

A common scenario that triggers this error is when a site-wide header wraps a component (like a card or widget) that has its own <header>. Another frequent mistake is accidentally duplicating <header> tags when copying markup or working with template partials.

To fix this issue, you have a few options:

  • Move the inner <header> outside the outer one entirely.
  • Place the inner <header> inside a sectioning element like <section> or <article> that is itself inside the outer <header> — though this is unusual and likely a sign of a structural problem.
  • Replace the inner <header> with a non-landmark element like <div> if it doesn’t truly represent introductory content for a section.

Examples

Incorrect: nested <header> elements

This markup nests a <header> for a featured article directly inside the page’s <header>, which is invalid:

<header>
  <h1>Welcome to Our Shop</h1>
  <header>
    <h2>Featured Product</h2>
    <p>Check out our latest arrival!</p>
  </header>
</header>

Correct: use a <div> for the inner grouping

If the inner content is simply a visual grouping within the same header, replace the nested <header> with a <div>:

<header>
  <h1>Welcome to Our Shop</h1>
  <div>
    <h2>Featured Product</h2>
    <p>Check out our latest arrival!</p>
  </div>
</header>

Correct: move the inner <header> into its own sectioning element

If the inner <header> truly introduces a distinct section of content, move it into an <article> or <section> outside the page header:

<header>
  <h1>Welcome to Our Shop</h1>
  <nav>
    <ul>
      <li><a href="/toys">Toys</a></li>
      <li><a href="/books">Books</a></li>
      <li><a href="/shoes">Shoes</a></li>
    </ul>
  </nav>
</header>

<article>
  <header>
    <h2>Featured Product</h2>
    <p>Check out our latest arrival!</p>
  </header>
  <p>Product details go here.</p>
</article>

Correct: deeply nested case with a sectioning element in between

A <header> can appear inside a sectioning element that is itself inside another <header>, because the inner <header> is no longer a descendant of the outer <header> in terms of the content model — wait, actually it still is a descendant. The spec says the <header> must not appear as a descendant at any depth. So the only valid fix is to ensure no <header> exists anywhere inside another <header>:

<!-- Invalid: even with an article in between, it's still nested -->

<header>
  <article>
    <header>
      <h2>News</h2>
    </header>
  </article>
</header>

<!-- Valid: move the article outside the header -->

<header>
  <h1>My Site</h1>
</header>

<article>
  <header>
    <h2>News</h2>
  </header>
  <p>Article content here.</p>
</article>

The key takeaway is straightforward: a <header> should never contain another <header>, regardless of how many elements sit between them. Restructure your HTML so each <header> lives in its own sectioning context, and your document will be valid, accessible, and semantically clear.

Find issues like this automatically

Rocket Validator scans thousands of pages in seconds, detecting HTML issues across your entire site.

Help us improve our guides

Was this guide helpful?

Ready to validate your sites?
Start your free trial today.