Skip to main content

HTML Guide

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

A main element cannot be nested within another main element.

The main element represents the primary content of a document or application, and there must be only one per page, not placed inside another main. The main element must not be used as a descendant of another main element. This is important for accessibility, semantic correctness, and helps screen readers correctly identify the main content region.

Invalid example (nested main):

<main>
  <h1>Welcome</h1>
  <main>
    <p>This nested main element is invalid.</p>
  </main>
</main>

Valid example (single main only):

<main>
  <h1>Welcome</h1>
  <section>
    <p>This section is valid and can be placed inside main.</p>
  </section>
</main>

If you need to divide the main content, use sectioning elements like section, article, or div inside a single main element, but never nest main inside main.

Learn more:

Related W3C validator issues