Title: Ensuring a Single Main Landmark for Better Accessibility
Rule ID: landmark-one-main
Ruleset: axe-core 4.10
User Impact: Moderate
Guidelines: Deque Best Practice
How to Fix the Problem
To improve accessibility and compliance with best practices, ensure your web page contains only one <main>
landmark. This landmark represents the primary content of the page and helps screen reader users quickly locate the core material.
Here’s how to fix this:
-
Use Only One
<main>
orrole="main"
Element:-
Only one
<main>
tag or element withrole="main"
should be present per page. -
Example:
-
-
Contain All Major Content in Landmark Regions:
-
Wrap content in appropriate HTML5 landmark tags:
-
<header>
withrole="banner"
-
<nav>
withrole="navigation"
-
<main>
withrole="main"
-
<footer>
withrole="contentinfo"
-
-
This ensures screen reader users can easily skip to key sections of the page.
-
-
Handle
<iframe>
Correctly:-
If you use
<iframe>
elements, ensure:-
Each iframe has zero or one main landmark inside it.
-
Avoid adding multiple main roles within the iframe content.
-
-
-
Combine HTML5 Tags with ARIA Roles:
-
For enhanced compatibility, use both the HTML5 tag and ARIA role (redundant but more robust).
-
Example structure:
-
-
Avoid Nesting Main Landmarks:
-
Never nest a
<main>
tag inside another landmark region or another<main>
tag.
-
Why it Matters
For users of assistive technologies such as screen readers, landmarks act as navigational waypoints. A single, clear <main>
region ensures they can quickly locate the primary content of a page.
Multiple <main>
landmarks confuse screen reader users, who might expect only one route to the core content. If content is outside recognized landmark regions, it can be skipped or misunderstood, significantly reducing usability and accessibility.
As HTML5 fills gaps that older HTML versions had, such as the lack of semantic structure, following these best practices helps your page remain future-proof and accessible.
Rule Description
This rule enforces the practice that each web page must include only one main
landmark. This helps define the primary content area clearly for assistive technologies. Pages that include iframes must also ensure each iframe contains either zero or exactly one main
landmark.
The Algorithm (in Simple Terms)
-
Scan the page for
<main>
tags or elements withrole="main"
. -
Flag an issue if:
-
More than one
main
landmark exists. -
Any iframe contains more than one
main
landmark.
-
-
Verify that all content is placed within appropriate landmark regions to enhance navigability.