NAV landmark must contain only region or search landmarks
Description
This rule checks that elements with role="navigation" (navigation landmarks) contain only allowed landmark roles as children. According to the WAI-ARIA landmark design principles, a navigation landmark should only contain region or search landmarks as direct or indirect children. Other landmark roles such as banner, main, complementary, contentinfo, or form are not permitted inside a navigation landmark, as this creates ambiguous or conflicting document structure for assistive technologies.
Disabilities impacted
- Visual impairments: screen reader users rely on landmarks to quickly navigate between major sections of a page. When a
navigationlandmark contains other inappropriate landmarks, the landmark structure becomes confusing. Users may struggle to understand the hierarchy of the page and may miss important content when using landmark navigation shortcuts. - Cognitive disabilities: users with cognitive disabilities benefit from predictable and consistent page structures. Landmarks provide a clear mental model of page organization. Nesting incorrect landmarks within a navigation element disrupts this model and can cause disorientation.
- Motor impairments: users who navigate via keyboard or voice commands often use landmark shortcuts to jump between page sections. Improper landmark nesting can cause these shortcuts to land in unexpected locations, requiring additional navigation effort and potentially causing frustration.
Why it matters
Landmarks are a fundamental way for assistive technology users to understand and navigate page structure. The WAI-ARIA specification defines specific landmark roles and establishes rules about how they can be nested. Navigation landmarks are intended to contain navigation – related content – such as link collections, menus, and site navigation structures. When other landmarks (like banner, main, or complementary) are placed inside a navigation landmark, it creates a nested landmark structure that violates ARIA authoring practices and can confuse assistive technology users. The allowed exceptions – region and search landmarks – provide flexibility for grouping content within navigation while maintaining logical landmark hierarchy.
Coding problems and solutions
Common coding problems
- Nested main landmark: a
role="main"element is placed inside arole="navigation"element, implying that the page’s primary content is inside navigation. - Nested banner landmark: a
role="banner"(typically page header content) appears inside navigation, creating ambiguity about what constitutes site-wide header content. - Nested complementary landmark: a
role="complementary"(supporting content like sidebars) is placed inside navigation, which is semantically incorrect. - Nested contentinfo landmark: a
role="contentinfo"(footer content like copyright) appears inside navigation, violating document structure expectations. - Nested form landmark: a
role="form"is placed inside navigation when it should be independent or properly scoped.
How to fix it
Restructure landmarks to avoid nesting inappropriate roles
Move inappropriate landmarks outside of the navigation landmark so they exist as siblings or at appropriate levels in the document hierarchy.
<!-- Navigation landmark with allowed content -->
<nav aria-label="Main menu">
<ul>
<li><a href="/">Home</a></li>
<li><a href="/about">About</a></li>
<li><a href="/contact">Contact</a></li>
</ul>
<!-- region is allowed inside navigation -->
<div role="region" aria-label="quick links">
<a href="#content">Skip to content</a>
</div>
</nav>
<!-- Main landmark is a sibling, not nested inside navigation -->
<main>
<h1>Page Content</h1>
<p>Main content goes here...</p>
</main><!-- Incorrect: main landmark inside navigation -->
<nav aria-label="Main menu">
<ul>
<li><a href="/">Home</a></li>
<li><a href="/about">About</a></li>
</ul>
<main>
<h1>Welcome</h1>
<p>This should not be inside navigation!</p>
</main>
</nav>Use region or search landmarks for content grouping within navigation
If you need to group content inside a navigation landmark, use role="region" or role="search" as these are the only allowed nested landmarks.
<nav aria-label="Main menu">
<!-- Main navigation links -->
<ul>
<li><a href="/">Home</a></li>
<li><a href="/products">Products</a></li>
<li><a href="/support">Support</a></li>
</ul>
<!-- Search landmark is allowed inside navigation -->
<div role="search">
<label for="site-search">Search site:</label>
<input type="search" id="site-search" name="q">
<button type="submit">Search</button>
</div>
<!-- Region landmark is allowed inside navigation -->
<div role="region" aria-label="user actions">
<a href="/account">My Account</a>
<a href="/cart">Cart (3)</a>
</div>
</nav>Remove unnecessary landmark roles from child elements
If child elements do not need landmark roles, remove the role attributes entirely or use standard HTML elements that do not imply landmark semantics.
<!-- No nested landmarks, just standard HTML -->
<nav aria-label="Main menu">
<div class="nav-container">
<ul>
<li><a href="/">Home</a></li>
<li><a href="/blog">Blog</a></li>
</ul>
<div class="nav-controls">
<button aria-label="Menu">☰</button>
</div>
</div>
</nav><!-- Unnecessary complementary role inside navigation -->
<nav>
<div role="complementary">
<p>Sponsored links</p>
<a href="#">Ad 1</a>
<a href="#">Ad 2</a>
</div>
</nav>Use HTML5 elements instead of explicit ARIA roles when possible
HTML5 semantic elements have implicit landmark roles. The <nav> element has an implicit role="navigation". Avoid nesting other semantic sectioning elements like <main>, <header> (when scoped to page), <footer> (when scoped to page), or <aside> inside <nav>.
<!-- Using HTML5 nav element (implicit navigation role) -->
<nav aria-label="Main menu">
<ul>
<li><a href="/">Home</a></li>
<li><a href="/about">About</a></li>
</ul>
</nav>
<!-- main element is separate, not inside nav -->
<main>
<h1>Page Title</h1>
</main>Known Limitations
- Dynamic landmark changes: This rule checks the DOM at analysis time. If landmark roles are added or removed dynamically via JavaScript, the rule must be re-run after changes.
- aria-owns relationships: This rule checks DOM hierarchy, not relationships defined by
aria-owns. Elements that are programmatically associated outside the DOM tree may not be detected. - Custom landmark roles: This rule only checks standard WAI-ARIA landmark roles. Custom roles not defined in the ARIA specification are not evaluated.
- Hidden navigation landmarks: Navigation landmarks with
aria-hidden="true"are still checked by this rule, as they may become visible or affect document structure when hidden conditions change. - Best practice rule: This is a best practices rule (not strictly required by WCAG), but following it significantly improves the user experience for assistive technology users and aligns with ARIA authoring practices.
Resources
- W3C WAI-ARIA: navigation role
- W3C WAI-ARIA: region role
- W3C WAI-ARIA: search role
- MDN Web Docs: navigation role
- MDN Web Docs: region role
- MDN Web Docs: search role
- W3C ARIA Authoring Practices Guide: Landmark Regions
Rule
- Audit: Accessibility
- Standard: SiteLint Best Practices
- Level: Best Practice
- Success Criteria: N/A (Best Practice Rule)
- ID:
navigation-landmark-restrictions - Report Message:
Elements with a role inside role="navigation" must only be role="region" or role="search".