Sub topic 11
Landmarks, accessible names, and skip links
This chapter assumes you can write basic HTML and CSS and that you have used the browser developer tools. It also assumes you know the semantic elements from earlier chapters: header, nav, main, section, and footer. Here you will see how those elements help keyboard and screen reader users move around a page.
Landmarks: the page's map
A landmark is a region of the page that assistive technology can list and jump to. Screen reader users often open a list of landmarks first, much as sighted users scan a page for its header and footer. Semantic elements create landmarks automatically, so you rarely need to add extra attributes.
| Element | Landmark role | Notes |
|---|---|---|
| `header` | banner | Only when it is a direct child of `body`. |
| `nav` | navigation | Use for major groups of links. |
| `main` | main | Use exactly one per page. |
| `section` | region | Only when it has an accessible name. |
| `footer` | contentinfo | Only when it is a direct child of `body`. |
A header or footer nested inside an article or section is not a page-level landmark. A section with no accessible name is not a landmark either, which is why naming matters.
Accessible names
An accessible name is the label a screen reader announces for an element. A page often has more than one nav, so a user who hears "navigation, navigation" cannot tell them apart. Give each one a distinct name with aria-label.
<header>
<nav aria-label="Primary">...</nav>
</header>
<footer>
<nav aria-label="Footer">...</nav>
</footer>A screen reader now announces "Primary navigation" and "Footer navigation". Do not put the word "navigation" in the label, because the role already supplies it.
You can also name a region from a visible heading with aria-labelledby. This is the pattern the hero uses:
<section class="hero" aria-labelledby="hero-title">
<h1 id="hero-title">Fresh bread, baked every morning</h1>
<p>Order ahead and pick up warm loaves on your way to work.</p>
</section>The section is now a named region, and its name matches the heading that sighted users read. Prefer aria-labelledby when a visible heading exists, so the spoken name and the visible text cannot drift apart.
Skip links
A keyboard user moves through the page with the Tab key. Without help, they must tab through every header link before reaching the content, and they repeat that on every page. A skip link is the first link in the body. It jumps straight to main.
<body>
<a class="skip-link" href="#main">Skip to main content</a>
<header>
<nav aria-label="Primary">...</nav>
</header>
<main id="main">
...
</main>
<footer>
<nav aria-label="Footer">...</nav>
</footer>
</body>The link's href matches the id on main. Following it moves focus to the content, so the next Tab press lands on the first interactive element inside main.
Most sighted mouse users do not need the link, so it is usually hidden until it receives focus. Move it off-screen and 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;
}Do not hide it with display: none or visibility: hidden. Those remove the link from the tab order, so keyboard users could never reach it.
Common errors
- Two
mainelements. Screen readers cannot tell which is the real content. Keep one per page. - Unnamed repeated landmarks. Two
navelements with no labels sound identical. - A skip link that points nowhere. If the
hrefdoes not match anid, nothing happens. Check the spelling. - Hiding the skip link with
display: none. It then never receives focus. - Removing the focus outline. Keyboard users lose track of where they are. If you restyle focus, keep a visible indicator.
Exercise
A page has a primary navigation in the header and a second navigation of legal links in the footer. Both are plain nav elements. What problem does a screen reader user face, and how do you fix it?
Show answer
Both landmarks are announced simply as "navigation", so the user cannot tell which is which. Give each a distinct accessible name, for example <nav aria-label="Primary"> in the header and <nav aria-label="Footer"> in the footer.
Exercise
A developer hides the skip link with display: none and shows it on hover. Why does this fail for keyboard users, and what CSS pattern fixes it?
Show answer
An element with display: none is removed from the tab order, so it can never receive focus, and a keyboard user does not hover. Position the link off-screen with position: absolute and a negative top, then set top to a positive value in a .skip-link:focus rule so it appears when focused.