Skip link

A skip link is a link placed first on a web page that lets keyboard and screen reader users jump past the repeated header and navigation straight to the main content. It is usually hidden until it receives keyboard focus, and it is the commonest way to meet WCAG Success Criterion 2.4.1 Bypass Blocks, which sits at Level A.

The longer version

Someone who moves through a page with Tab passes every link in the header and the main navigation before reaching the content, and on a site where that block repeats, they pass it again on every page. WCAG 2.2 Success Criterion 2.4.1 Bypass Blocks, Level A, says: A mechanism is available to bypass blocks of content that are repeated on multiple web pages. The W3C's Understanding document gives its intent as allowing people who navigate sequentially through content more direct access to the primary content of the web page. The skip link is the first of its sufficient techniques, G1, adding a link at the top of each page that goes directly to the main content area. Others group the repeated material instead, with ARIA landmarks (ARIA11) or a heading at the start of each section (H69). Screen readers have commands to jump between landmarks and headings, and WebAIM's article on skip navigation links notes that a browser on its own has no such command, so a sighted keyboard user gains little from them; WebAIM strongly recommends a skip link on pages with repeated navigation. The usual wording is Skip to main content or Skip to content.

W3C Technique G1 sets out the behaviour in its test procedure. The link is the first focusable control on the page. Its text says that it goes to the main content. It is either always visible or visible when it has keyboard focus: the technique calls a link visible at all times preferable, and says 2.4.1 does not require visibility before focus. Activating it moves keyboard focus to the main content. In markup that is an anchor whose href is #main, placed straight after the opening body tag, and a main element with the id main. The link is hidden by moving or clipping it off screen and brought back on :focus, never with display: none or the hidden attribute, which WebAIM notes take it out of keyboard navigation altogether. GOV.UK's design system places it immediately after the opening body tag, after the cookie banner where there is one, and never inside a nav region or the header. A target that cannot take focus by default can be given a tabindex of -1, which MDN describes as keeping an element out of sequential keyboard navigation while letting focus be set on it. GOV.UK's component also moves focus to the target with JavaScript, a change made in version 4.0.0 in December 2021 to make screen reader behaviour more consistent.

The defects repeat from site to site. The link is hidden permanently, with display: none, or moved off screen with no :focus rule to bring it back, so focus lands on something nobody can see, which also fails 2.4.7 Focus Visible. It appears on focus with no focus indicator, or in a colour that barely differs from the header behind it. It is not first, because a logo link, a search field or a chat widget comes before it in the source. Its target does not exist, because the id was renamed or the template has no main element, so activating it does nothing. Its target exists and cannot take focus, so the page scrolls while focus stays at the top and the next Tab goes back into the header; a single-page app whose router intercepts hash links fails the same way. A sticky header covers the start of the main content once the page has jumped, the 2.4.11 Focus Not Obscured failure the focus indicator entry describes. GOV.UK's component page records one more: after a user follows the skip link and then a button, the fragment can stay in the url, so pages that load afterwards may skip to the main content without being asked.

The test takes a keyboard and a minute per template. Load the page, click the address bar and press Tab once. The skip link should appear, with a visible focus indicator and text that says where it goes. On a Mac, tick Press Tab to highlight each item on a webpage in Safari Settings, under Advanced, first, or Safari will pass over the link. Press Enter. The view should move to the main content, and the next Tab should land on the first interactive element inside it, never back in the header. Repeat on each template that carries the repeated block, such as the home page, an article, a form and the checkout, in each browser the project supports, then once with a screen reader to hear the link announced. A finding names the page, the browser, the step that failed and the criterion: 2.4.1 for a link that is missing or goes nowhere, 2.4.7 for one that takes focus and stays invisible. A short screen recording of the Tab sequence shows the failure faster than a sentence. The accessibility checklist in the Notarus templates carries 2.4.1 in its Keyboard and focus group, with the skip link as its example.

Common questions

What is a skip link?

A skip link is a link at the very start of a web page, usually reading Skip to main content, that takes keyboard and screen reader users past the header and navigation to the main content. Most sites hide it until it receives focus from the Tab key, so it appears only for people who navigate by keyboard.

Is a skip link required by WCAG?

WCAG 2.2 Success Criterion 2.4.1 Bypass Blocks, Level A, requires a mechanism to bypass blocks of content repeated on multiple pages. A skip link is the first sufficient technique the W3C lists, and ARIA landmarks and headings are others. A page can meet the criterion without one, though WebAIM strongly recommends a skip link wherever navigation repeats.

What is an example of a skip to content link?

The commonest example is a link reading Skip to main content, placed as the first element after the opening body tag, whose href is #main and whose target is the main element with the id main. Pressing Tab on the page shows it, and pressing Enter moves focus to the start of the content.

How do I add a skip link to a website?

Put an anchor that points at the main content's id as the first focusable element in the body, give the main element that id, and give it a tabindex of -1 if focus does not arrive there. Hide the link off screen with CSS and bring it back on :focus, never with display: none. Then test it with Tab and Enter in each browser.

Should a skip link always be visible?

W3C Technique G1 calls a link visible at all times preferable, and says WCAG 2.4.1 does not require it to be visible before it has focus. A link that appears when it receives keyboard focus meets the criterion. A link that stays invisible while focused fails 2.4.7 Focus Visible, because the keyboard user cannot see where focus is.

Why does my skip link not move focus?

Usually the target cannot receive focus, so the browser scrolls and leaves focus where it was, or the target id does not exist on that template. A tabindex of -1 on the main element, or moving focus to it with script as GOV.UK's component does, fixes the first. A single-page app router that intercepts hash links causes the same symptom.

Does a page need more than one skip link?

Most pages need one, pointing at the main content, and WebAIM says the same. W3C Techniques G123 and G124 describe a link at the start of a repeated block that jumps to its end, and links at the top of the page to each area of the content, which can help on long pages with several large blocks.

Bug reports that arrive ready to triage.

Collect replay, console, network and browser context with the Free plan.

<script src="…/widget.js" data-key="pb_pub_…">