Disallows multiple <main> elements in the same document

Rule ID:
no-multiple-main
Category:
Content model
Standards:
  • HTML5

HTML5 disallows multiple visible <main> element in the same document. Multiple <main> can be present but at most one can be visible and the others must be hidden using the hidden attribute.

Rule details

Examples of incorrect code for this rule:

<main>foo</main>
<main>bar</main>
error: Multiple <main> elements present in document (no-multiple-main) at inline:2:2:
  1 | <main>foo</main>
> 2 | <main>bar</main>
    |  ^^^^


1 error found.

Examples of correct code for this rule:

<main>foo</main>
<main hidden>bar</main>