Landmarks, skip links and page structure for screen readers
Build semantic, accessible and responsive interfaces from a blank page, and explain why each layout and styling decision works.
What you will be able to do
#- Provide a skip link that becomes visible on focus.
- Structure a page so landmark navigation is complete and unique.
Overview
#A skip link lets keyboard users jump past repeated navigation straight to the main content. It is the first focusable element on the page and is usually visually hidden until it receives focus.
<a class="skip-link" href="#main">Skip to main content</a>
<header>...</header>
<main id="main" tabindex="-1">...</main>
.skip-link {
position: absolute;
left: -9999px;
}
.skip-link:focus {
left: 0;
top: 0;
background: #fff;
padding: 0.5rem 1rem;
z-index: 100;
}
Do not hide the skip link with display: none or visibility: hidden, because those remove it from the tab order. Move it off screen and bring it back on :focus. The target of the link needs tabindex="-1" so focus actually moves there; without it, some browsers scroll without moving focus.
Landmarks should be complete and unambiguous. One main, one banner, one contentinfo, and a nav for each distinct navigation area with a unique accessible name when there is more than one. Screen reader users can then jump between regions instead of tabbing through every link. Duplicate or missing landmarks force them back to linear reading.
Headings are the other structure layer. Use one h1 per page, do not skip levels for styling, and make each heading describe the section beneath it. Heading navigation is often the fastest way to understand an unfamiliar page.
Exercises
#Reference answers and expected output are authored, not executed in this browser. Nothing you type is run, and there is no Run or Pass control on this page.
Exercise 1Implement
Add a skip link that is off screen until focused and targets the main content.
starter.html<body> <header>Site nav</header> <main>Content</main> </body>Reveal the reference answer
reference.html<body> <a class="skip-link" href="#main">Skip to main content</a> <header>Site nav</header> <main id="main" tabindex="-1">Content</main> </body> <style> .skip-link { position: absolute; left: -9999px; } .skip-link:focus { left: 0; top: 0; background: #fff; padding: 0.5rem 1rem; } </style>Authored expected output: A skip link is the first focusable element, hidden off screen until focused, and the main element has tabindex="-1".
Off-screen positioning keeps the link in the tab order, and tabindex="-1" on main lets focus land there.
Common misconceptions
#- A skip link can be hidden with display:none because it is only for keyboard users.
- Heading levels should be chosen for their font size.
Follow-up practice
#- html-css-16-normal-flow-box-model
Your progress
#Answers, drafts and completion marks are stored only in this browser. Nothing is sent to a server and no account is used.
Verification: authored. Answers and outputs on this page are authored reference material, not executed results.