Sub topic 3
Structuring a page with landmarks
This chapter assumes you know basic HTML syntax (tags, attributes, nesting) and can open your browser's developer tools. CSS knowledge helps but is not required.
What landmarks are
A landmark is a region of a page that the browser exposes to assistive technology under a name. Screen reader users can list the landmarks on a page and jump straight to one, such as the main content, instead of listening through everything above it.
Five elements create most landmarks:
| Element | Landmark role | Purpose |
|---|---|---|
| `header` | `banner` (see the note below) | Site-wide introduction: logo, site name, top-level links |
| `nav` | `navigation` | A block of links for moving around the site or page |
| `main` | `main` | The central content unique to this page |
| `aside` | `complementary` | Content related to, but separate from, the main content |
| `footer` | `contentinfo` (see the note below) | Copyright, legal links, contact details |
A page skeleton
<body>
<header>
<a href="/">Example Site</a>
<nav aria-label="Primary">
<ul>
<li><a href="/articles">Articles</a></li>
<li><a href="/about">About</a></li>
</ul>
</nav>
</header>
<main>
<h1>Latest articles</h1>
<p>Pick an article to start reading.</p>
</main>
<aside aria-label="Related links">
<p>Subscribe to the newsletter.</p>
</aside>
<footer>
<p>© Example Site</p>
</footer>
</body>Each region has one job. The nav sits inside the header because the navigation belongs to the site's introduction. The main holds the h1 and the content a visitor came for. The aside and footer follow it.
Rules to follow
- Use exactly one visible
mainper page. It must not sit insideheader,nav,asideorfooter. - Do not repeat content in
mainthat appears on every page, such as site navigation. - Label a landmark when the page has more than one of its kind. Two unlabeled
navelements both announce as "navigation", and users cannot tell them apart. - Use
aria-labelfor a short name, oraria-labelledbyto point at an existing visible heading. - Do not label with the role's own name.
aria-label="Navigation"on anavis read as "Navigation navigation".
Here a page has two navigation regions, each with its own name:
<nav aria-label="Primary">
<a href="/articles">Articles</a>
<a href="/about">About</a>
</nav>
<nav aria-label="Breadcrumb">
<a href="/">Home</a>
<a href="/articles">Articles</a>
</nav>How the regions fit together
Common errors
- Landmarks everywhere. If every region is a landmark, the list stops being useful. Reserve them for the major areas of the page.
- Content outside any landmark. A screen reader user who navigates by landmark may never reach text that sits in a bare
divbeside them. - Using
asidefor layout. Chooseasidebecause the content is tangential, not because it appears in a sidebar column. Layout belongs to CSS. - Wrapping the whole page in
main. This removes the navigation benefit, because the landmark then covers everything.
Check it in the browser
Open devtools and inspect the Accessibility pane for each element. The pane shows the computed role and name. Confirm that main reports the role main and that each nav shows the name you gave it.
Exercise
A page has a primary menu and a "Related topics" link list, both marked up with nav. A screen reader lists two "navigation" landmarks with no way to tell them apart. What is the fix, and what should you avoid writing in the label?
Show answer
Give each nav a distinct accessible name, for example aria-label="Primary" on the menu and aria-label="Related topics" on the other. Avoid putting the word "navigation" in the label, because the role is already announced and the user would hear "Primary navigation navigation".