landmark-no-duplicate-main

Page must not have more than one main landmark

manualconfidence: mediumseverity: minoroperable

Checks that at most one main landmark (role="main" or <main>) exists on the page.

Applies to. Applies whenever the page contains at least one main landmark (explicit role="main", or an implicit <main>). A custom element whose ElementInternals give it a landmark role (this.attachInternals().role), with no role attribute naming another, is a landmark as a native element with that role is.

Expectation. At most one main landmark exists on the page. Distinct, atomic decision from landmark-one-main (that rule flags zero mains too; this one only flags more than one).

What a finding reports.

  • count: how many main landmarks the page exposes to assistive technology, against a limit of 1.

These data.details fields help to read and reproduce a finding. Apart from reasonCode and the few fields Output schema names as stable, they are not a stable contract: a field may be renamed or dropped in a minor release, so don’t build on them.

Examples

pass
<body>
<main>Only one</main>
</body>

Only one main landmark exists.

can't tell
<body>
<main>First</main>
<main>Second</main>
</body>

Two <main> elements are both exposed to assistive technology as main landmarks.

How to check

When this rule can’t decide, it reports cantTell and leaves the question to a person. Each question it can ask is listed here under its reason code, with the steps to answer it. A finding carries the same steps as howToCheck, in the scan’s language. See Output schema.

LANDMARK_DUPLICATE_MAIN

  1. Open a screen reader's landmarks list, or the Accessibility pane, and count the main landmarks.
  2. For each one the report names, decide which holds the page's primary content.
  3. Check that any other main is hidden (the hidden attribute) when it is not the current view.

Pass. Assistive technology finds only one main landmark, around the page's primary content.

Fail. More than one main is exposed, so users cannot tell which is the primary content, a best-practice miss under the WAI-ARIA main role and HTML's rule of one visible main.

View source