NAV-004 Start a page with a skip link when links come before its main content
- Level
- Guideline, our choice
- Verdict
- Insufficient evidence (1 of 3 judges spoke)
- Area
- Navigation
- Status
- proposed, version 1.0.0
Rule
When a header or sidebar with links comes before a page's main content, make a skip link the first thing Tab reaches. It is visible while it has focus, and it moves focus to the start of the main content.
Examples
Live examples built with Justified's components. Try them with the mouse, the keyboard or a screen reader.
Do: A visible skip link goes to the content
Don't: No skip link
Don't: A skip link that is never shown
Don't: The target hides its focus ring
Why
A keyboard user moves through a page one stop at a time, from the top. When the page opens with a header and a sidebar of twenty links, they pass all twenty on every page before they reach what they came for. WCAG 2.2, 2.4.1 Bypass Blocks requires a way past blocks that repeat across pages, but it accepts several ways, and landmarks built as STR-004 asks are one of them (Understanding 2.4.1). A page with a correct main can meet the criterion without a skip link, so the skip link is our choice, not something WCAG requires. Once it is there, 2.4.7 Focus Visible applies to it like any other link: a skip link that stays hidden while it has focus fails that criterion.
Our reasons
Fewer than two judges have spoken about a skip link, so the verdict is Insufficient evidence (1 of 3 judges spoke) and this guideline is our choice. Carbon supports it. So do GOV.UK and NN/g, expert witnesses who do not vote. We ask for it for three reasons.
- Landmarks do not reach everyone. A screen reader can jump to
main. Most browsers give a sighted keyboard user without a screen reader no key for that, so for them the landmarks of STR-004 change nothing, and the long sidebar still costs them a press per link. - It is found without looking for it. The first press on Tab shows it. Nobody has to know a shortcut or that the page has landmarks.
- It costs almost nothing. One link, hidden until it has focus, takes no space and is skipped with one more press by anyone who wants the menu.
Do
- In the invoicing app Tallowbrook, the first Tab on any page shows Skip to main content in the top left corner, over the header, with the usual focus ring from KBD-001. Enter moves focus to the start of the invoice list, so the next Tab lands on the list's first control, not in the sidebar.
- Put the link first in the code, before the logo, the header and the sidebar, not only first on screen (LAY-002). If the page shows a cookie banner, the link comes right after it.
- In a shadcn layout, place it before the
SidebarinsideSidebarProvider, with the adapter'sfocusRingclasses so its ring is the one KBD-001 describes:<a href="#main-heading" className={cn("sr-only focus:not-sr-only focus:fixed focus:left-4 focus:top-4 focus:z-50 focus:bg-background focus:px-4 focus:py-2", focusRing)}>Skip to main content</a>. - Give the target an
idand make it able to take focus from script withtabIndex={-1}. Without it, some browsers scroll to the target but leave focus at the top, so the next Tab goes back into the menu. - Our own advice: point the link at the view's
h1insidemain, such as<h1 id="main-heading" tabIndex={-1}>Invoices</h1>, rather than atSidebarInset, which rendersmain. The focus indicator then shows on the heading, small and exactly where focus went. Pointing atmainitself also works, and then the ring goes round the whole content area. - Keep the visible focus indicator on the target as well, as KBD-001 asks of anything with keyboard focus.
- Let the text say where it goes: Skip to main content.
- Keep it outside
navand outside the header, on its own. If an automated checker reports it as content outside a landmark, leave it where it is. - When a sticky header would cover the target after the jump, add
scroll-mtto the target, so it stays in view as KBD-002 asks. - In an app that changes views without loading a page, focus can stay on the sidebar link that was pressed, behind the skip link. Where focus goes after a view change is outside this guideline; STR-001 covers the title that changes with it.
Don't
- Build a
SidebarProviderlayout with no skip link, so the first twenty presses on Tab walk the sidebar on every page. - Give the link
className="sr-only"with nofocus:not-sr-only, so it gets focus but is never seen. - Hide it with
display: noneorhidden, so it never gets focus at all. - Point it at
#main-headingwhen no element has thatid, or put theidon a wrapper outsidemain. - Put
outline-noneon the skip target to hide its ring, so the person cannot see where focus went. - Put it inside the sidebar's
nav, after the logo or after the first menu links.
Exceptions
- No links before the content. A sign-in page with only a form, a full-screen editor or a checkout flow without the product's menu needs no skip link.
- Navigation after the content. When the menu comes after the main content in the code, the first Tab already lands in the content.
- Dialogs. A dialog is not covered; focus inside it is DLG-006 and DLG-007.
- A product that chooses otherwise. This is a guideline. A page without a skip link still needs some way past its repeated blocks, which the landmarks of STR-004 can give.
Verdict
Insufficient evidence (1 of 3 judges spoke). Only the judges decide; the expert witnesses are shown but do not vote. The judges do not settle this one, so it is a guideline: our own choice, with our reasons above. How verdicts work
| Source | Role | Stance | Page |
|---|---|---|---|
| WCAG 2.2 | Law | Supports | 2.4.1 Bypass Blocks |
| WCAG 2.2 | Law | Supports | 2.4.7 Focus Visible |
| Material Design | Judge | No position | |
| Apple Human Interface Guidelines | Judge | No position | |
| Carbon Design System | Judge | Supports | UI shell header: usage UI shell header: Accessibility |
| GOV.UK Design System | Expert witness | Supports | Skip link Breadcrumbs Help users to navigate a service |
| Nielsen Norman Group | Expert witness | Supports | Keyboard-Only Navigation for Improved Accessibility, by Marieke McCloskey |
Each stance links to the page it rests on, read on the date in the source register. This page never repeats what a source says; read the source itself.
History
- Version 1.0.0, : First version.
Last checked against the other rules for conflicts on .
More in Navigation: 3 rules and 1 guideline · All rules
Justified is an independent project. It is not affiliated with, sponsored or endorsed by the organisations whose guidance it cites. Read the full statement.
Apple is a trademark of Apple Inc., registered in the U.S. and other countries and regions.