Sub topic 11
Landmarks, Accessible Names, and Skip Links
This chapter assumes you can write basic HTML and CSS and know the semantic elements from the earlier chapters: header, nav, main, section, and footer. It also assumes you can open the browser developer tools. Here you will learn how those elements become landmarks, how to give landmarks accessible names, and how to add a skip link so keyboard users can bypass repeated content.
Why landmarks matter
A sighted mouse user scans a page visually and jumps to the part they want. A screen reader user cannot do that. A screen reader is software that reads page content aloud or sends it to a braille display. It offers a shortcut instead: a list of landmarks, which are named regions of the page. The user opens that list and jumps straight to "main" or "navigation".
Landmarks come from HTML elements, so the semantic markup you already wrote does most of the work. The job in this chapter is to check that the landmarks are correct, that they are named when needed, and that keyboard users have a way past the header.
How elements map to landmarks
Each semantic element exposes an ARIA landmark role. ARIA is a set of attributes that tell assistive technology what an element is. You rarely type the role yourself, because the browser assigns it.
| Element | Landmark role | Condition |
|---|---|---|
| `header` | `banner` | Only when it is a direct child of `body`, not nested inside `main`, `article`, or `section` |
| `nav` | `navigation` | Always |
| `main` | `main` | Always |
| `footer` | `contentinfo` | Only when it is a direct child of `body` |
| `section` | `region` | Only when it has an accessible name |
| `aside` | `complementary` | Always |
| `form` | `form` | Only when it has an accessible name |
The conditions are the part people miss. A header inside an article is just the heading area of that article, and it does not become the page banner. A section with no name is a generic grouping, and it does not appear in the landmark list.
One of each, in the right place
A well-formed page has these top-level landmarks:
- One
banner(the siteheader). - One
main. - One
contentinfo(the sitefooter). - One or more
navigationregions.
Pages should have exactly one visible main. Screen reader users treat it as "the start of the real content", so a second main breaks that expectation. Keep banner, main, and contentinfo as direct children of body, so they are not nested inside other landmarks.
Do not wrap everything in landmarks. If every div becomes a region, the landmark list turns into noise and users stop trusting it. Use landmarks for the large, stable parts of the page.
Accessible names
An accessible name is the text that assistive technology announces for an element. For a link it is the link text. For an image it is the alt text. For a landmark it is a label you supply.
You only need to name a landmark when the page has more than one of the same kind. A page with two nav elements announces "navigation" twice, and the user cannot tell them apart. Naming them fixes that.
There are two ways to supply a name:
aria-label="Primary"gives a name as a string.aria-labelledby="some-id"points at an element whose text becomes the name. Use this when a visible heading already describes the region, because the name then stays in sync with what sighted users read.
The skeleton from earlier in this tutorial used aria-label on the header navigation. Here is the footer counterpart, plus a named section that uses aria-labelledby:
<header>
<nav aria-label="Primary">
<ul>
<li><a href="/menu">Menu</a></li>
<li><a href="/about">About</a></li>
</ul>
</nav>
</header>
<main id="main">
<section aria-labelledby="specialties-title">
<h2 id="specialties-title">Our specialties</h2>
<p>Sourdough, rye, and seasonal pastries.</p>
</section>
</main>
<footer>
<nav aria-label="Footer">
<ul>
<li><a href="/privacy">Privacy</a></li>
<li><a href="/contact">Contact</a></li>
</ul>
</nav>
</footer>A screen reader now lists "Primary navigation" and "Footer navigation". The section is announced as the region "Our specialties". The same aria-labelledby pattern works for the hero. In the hero example, aria-labelledby="hero-title" points to the h1, which turns the hero into a named region.
Naming rules that avoid common mistakes
- Do not put the role word in the name. Write
aria-label="Primary", notaria-label="Primary navigation". Screen readers already say "navigation", so the longer name is read as "Primary navigation navigation". - Keep names short and distinct. "Primary", "Footer", and "Breadcrumb" are good. "Links" is not distinct.
- Prefer visible text.
aria-labelledbypointing to a real heading beats a hiddenaria-label, because it cannot drift away from what the page says. - Do not name every
section. Naming asectionpromotes it to a landmark. Name only those that are significant enough to appear in a landmark list.
Skip links
Every page repeats the header and navigation. A mouse user ignores them. A keyboard user moves with the Tab key, one focusable element at a time, so they must tab through every header link on every page before reaching the content. A skip link removes that cost. It is the first link in the page, and it jumps focus to the main content.
The HTML has two parts: a link as the first element in body, and a target with a matching id.
<body>
<a class="skip-link" href="#main">Skip to main content</a>
<header>
<nav aria-label="Primary">...</nav>
</header>
<main id="main">
...
</main>
</body>The link href="#main" points to the element whose id is main. When the user presses Enter, the browser scrolls to that element and moves the keyboard position there.
Showing the link only on focus
Most sites keep the skip link out of sight until a keyboard user reaches it. Move it off-screen, then bring it back on focus:
.skip-link {
position: absolute;
left: 0.5rem;
top: -3rem;
padding: 0.5rem 1rem;
background: #fff;
color: #000;
}
.skip-link:focus {
top: 0.5rem;
}Moving the link off-screen with top keeps it in the tab order and the accessibility tree. Compare the alternatives:
| Technique | Result |
|---|---|
| `top: -3rem` (off-screen) | Still focusable, announced by screen readers, appears on focus |
| `display: none` | Removed from the tab order and from screen readers, so it never works |
| `visibility: hidden` | Same problem as `display: none` |
| `opacity: 0` without a focus style | Focusable but invisible, so sighted keyboard users cannot see where focus is |
Hiding with display: none is the most common bug. The link exists in the source but nobody can reach it.
Making the target receive focus
In most current browsers, following #main moves focus to main even though main is not normally focusable. Older browsers did not always do this, and the next Tab press could start from the top of the page again. If you need to support them, add tabindex="-1" to the target:
<main id="main" tabindex="-1">A tabindex of -1 makes an element focusable by script or by a link, but keeps it out of the normal Tab order. If you add it, also remove the outline that appears on main when it receives focus only if you provide another visible focus cue. Do not remove focus styling from interactive elements such as links and buttons.
Testing what you built
Check landmarks and the skip link with tools, not by eye alone.
- Unplug the mouse mentally and use only the keyboard. Reload the page and press Tab once. The skip link should appear. Press Enter and then Tab again. Focus should land on the first focusable element inside
main, not back in the header. - Open the accessibility tree in the browser developer tools. In Chrome and Edge, use the Accessibility panel in the Elements tab. In Firefox, use the Accessibility panel. Confirm the roles
banner,navigation,main, andcontentinfo, and that each navigation has the name you set. - Turn on a screen reader and open its landmark list: VoiceOver on macOS and iOS, NVDA or Narrator on Windows, TalkBack on Android. Each landmark should have a distinct, short name.
- Run an automated checker such as the Lighthouse accessibility audit or axe. These tools catch duplicate landmarks, missing
main, and unnamed repeated navigation. They cannot judge whether a name is meaningful, so read the results yourself.
Common failure modes
- Two
mainelements. Single-page apps sometimes render a newmainon each route without removing the old one. Keep only one visible. - Header inside
sectiontreated as the banner. It is not. Only a top-levelheaderis the banner. - Unnamed repeated navigation. Two
navelements with no names are indistinguishable. - Role words in names. "Footer navigation" read as "Footer navigation navigation".
- A skip link hidden with
display: none. It cannot be reached. - A skip link target that does not exist. The
hrefand theidmust match exactly, including case. - Everything is a landmark. Too many named regions make the list useless.
Exercises
Exercise
A page has a top-level header with a nav, a main, and a footer that contains a second nav with links to legal pages. Which landmark needs an accessible name, and what would you write?
Show answer
Both nav elements need names, because the page has two navigation landmarks and they must be distinguishable. For example, <nav aria-label="Primary"> in the header and <nav aria-label="Footer"> in the footer. Do not add the word "navigation" to the names.
Exercise
A developer hides the skip link with .skip-link { display: none; } and shows it with .skip-link:focus { display: block; }. Why does this fail, and how should it be fixed?
Show answer
An element with display: none cannot receive focus, so the :focus rule never applies and keyboard users never reach the link. Fix it by moving the link off-screen with position: absolute; top: -3rem; and setting top: 0.5rem; on :focus, so the link stays focusable.
Exercise
You add <section> around the "Our specialties" content and it does not appear in the screen reader's landmark list. What do you add to make it a landmark, and what is a sensible way to choose the name?
Show answer
Give the section an accessible name. Add aria-labelledby pointing to the id of the section's heading, for example <section aria-labelledby="specialties-title"> with <h2 id="specialties-title">Our specialties</h2>. Using the visible heading keeps the name in sync with the page text.