Page structure
Skip link
A "Skip to main content" link that appears when someone presses Tab.
When to use
- On every page. Without it, keyboard users must Tab through the banner, header and menu on every page before reaching the content (WCAG 2.4.1).
When not to use
- Pointing anywhere other than the main content.
- More than once on a page.
How to use
- Make it the first element in
<body>, before the banner. - Point it at your main content:
<main id="main" tabindex="-1">. Thetabindex="-1"lets focus move to<main>, so the next Tab starts from the content, not from the top of the page. - Keep the words "Skip to main content".
- Give
<main>the classggds-main. It removes the focus outline from<main>itself. - Check it on every page template: load the page, press Tab once, then Enter.
Do
- Use the same skip link on every page.
Don't
- Hide it with
display: none; keyboard and screen reader users could not reach it. - Put the
id="main"on more than one element.
Accessibility
What GGDS does
- It is moved off screen, not hidden, so it stays in the Tab order and screen readers can always find it.
- When it has focus it appears at the top left, above everything else, in bold dark text on gold.
What you need to do
- Make it the first element in
<body>. - Point it at
<main id="main" tabindex="-1">, so focus really moves past the banner and menu. - Test it with a keyboard after any change to the page layout.
Example: Skip link (press Tab)
<a class="ggds-skip-link" href="#main">Skip to main content</a>
<main class="ggds-main ggds-container" id="main" tabindex="-1">
<p>Press Tab to show the skip link, then Enter to move to the main content.</p>
</main><>
<a className="ggds-skip-link" href="#main">Skip to main content</a>
<main className="ggds-main ggds-container" id="main" tabIndex={-1}>
<p>Press Tab to show the skip link, then Enter to move to the main content.</p>
</main>
</>Use it
- Stylesheet
ggds.cssincludes it. To load only the parts you use:core.css, thencomponents/skip-link.css(0.3 KB with gzip, minified).- JavaScript
- None needed.
HTML
Copy the HTML under each example above. It works in any website.
Astro
With @ggds/astro:
import SkipLink from '@ggds/astro/SkipLink.astro';
<SkipLink />React and Next.js
With @ggds/react:
import { SkipLink } from '@ggds/react';
<SkipLink />Django
With ggds-django ({% load ggds %}):
{% ggds_skip_link %}Classes and states
| Class | What it does |
|---|---|
.ggds-skip-link | The link. Hidden until it has keyboard focus, then shown at the top left of the page. |
| State | What it does |
|---|---|
:focus | Shown on screen while it has focus. |
Accessibility tests
Automated, on every change
These run each time GGDS changes. A change that fails one is not accepted.
- WCAG 2.2 A and AA rules (axe), at desktop and phone widths, on every example
- No sideways scrolling on a 320px screen, also with a wide font, on every example
- Every approved colour pair meets its contrast minimum, for every institution theme
- No inline scripts or styles, so it runs under a strict Content Security Policy
By people, with assistive technology
Automated tests find only some of the barriers people meet. These checks are still to be done.
| Check | Result | Notes |
|---|---|---|
| Keyboard only | Not tested yet | Waiting for the external audit with disabled people (decision D-09). |
| NVDA screen reader with Firefox or Chrome (Windows) | Not tested yet | Waiting for the external audit with disabled people (decision D-09). |
| JAWS screen reader with Chrome (Windows) | Not tested yet | Waiting for the external audit with disabled people (decision D-09). |
| VoiceOver screen reader with Safari (iPhone) | Not tested yet | Waiting for the external audit with disabled people (decision D-09). |
| TalkBack screen reader with Chrome (Android) | Not tested yet | Waiting for the external audit with disabled people (decision D-09). |
| Zoom to 400%, and increased text spacing | Not tested yet | Waiting for the external audit with disabled people (decision D-09). |
| Windows contrast themes (forced colours) | Not tested yet | Waiting for the external audit with disabled people (decision D-09). |
| Voice control (Voice Access or Dragon) | Not tested yet | Waiting for the external audit with disabled people (decision D-09). |
Changes
| Version | Change |
|---|---|
| 0.2.0 | Fuller guidance for tags, breadcrumbs, disclosures, the skip link, pagination, rich text, tables and tab links. |
| 0.1.0 | New: @ggds/astro, the page parts as Astro components (skip link, banner, header, hero, footer, tab bar). |
| 0.1.0 | New: ggds-django, for Django and Django-based CMSs such as Wagtail: the page parts as template tags, a form renderer that turns any Django form into GGDS markup with an error summary and accessible errors, and the GGDS styles, themes and script as static files. |
| 0.1.0 | Added. |
Related components
Something wrong, unclear or missing? or suggest a change to it on GitHub. You need a GitHub account.