Skip to content

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)
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

Then press Tab.
Skip to main content

Presses of Tab to reach New invoice: –

Press Start from the top of the page, then Tab. Skip to main content appears with its focus ring. Press Enter: focus lands on the heading Invoices, with its own ring, and one more Tab reaches New invoice. The count under the example says how many presses it took.

Don't: No skip link

Then press Tab.

Presses of Tab to reach New invoice: –

Start from the top and keep pressing Tab until New invoice has focus. Every header and sidebar control comes first, and this has to be done again on every page.

Don't: A skip link that is never shown

Then press Tab.
Skip to main content

Presses of Tab to reach New invoice: –

Start from the top and press Tab. The link does get focus, as the line under the example says, but nothing appears on screen, so a person who sees the page has no idea where focus is.

Don't: The target hides its focus ring

Then press Tab.
Skip to main content

Presses of Tab to reach New invoice: –

Start from the top, press Tab and then Enter. Focus moves to the heading, as the line under the example says, but the heading shows no ring, so the person cannot see where they now are.

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 Sidebar inside SidebarProvider, with the adapter's focusRing classes 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 id and make it able to take focus from script with tabIndex={-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 h1 inside main, such as <h1 id="main-heading" tabIndex={-1}>Invoices</h1>, rather than at SidebarInset, which renders main. The focus indicator then shows on the heading, small and exactly where focus went. Pointing at main itself 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 nav and 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-mt to 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 SidebarProvider layout with no skip link, so the first twenty presses on Tab walk the sidebar on every page.
  • Give the link className="sr-only" with no focus:not-sr-only, so it gets focus but is never seen.
  • Hide it with display: none or hidden, so it never gets focus at all.
  • Point it at #main-heading when no element has that id, or put the id on a wrapper outside main.
  • Put outline-none on 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

Stances on NAV-004
SourceRoleStancePage
WCAG 2.2LawSupports2.4.1 Bypass Blocks
WCAG 2.2LawSupports2.4.7 Focus Visible
Material DesignJudge No position
Apple Human Interface GuidelinesJudge No position
Carbon Design SystemJudge SupportsUI shell header: usage
UI shell header: Accessibility
GOV.UK Design SystemExpert witness SupportsSkip link
Breadcrumbs
Help users to navigate a service
Nielsen Norman GroupExpert witness SupportsKeyboard-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