Dostępność

a11y/skip-link

Pages with repeated header or navigation start with a "Skip to main content" link whose target exists and takes focus.

umiarkowanaw przeglądarceWCAG 2.4.1 · Afe-a11y-keyboard

Dlaczego

Without a way past the header, a keyboard user presses Tab through every navigation link on every page before reaching the content. Landmarks help screen reader users, but sighted keyboard users need the link.

Poprawka

Make the first focusable element of the layout <a href="#main" class="skip-link">Skip to main content</a>, give <main id="main" tabindex="-1">, and show the link when it has focus (visually hidden until :focus). Put it in the shared layout, not per page.

Przykłady

<!-- bad: the first Tab stop is the logo, then 30 menu links -->
<header><a href="/">Logo</a><nav>…</nav></header>
<!-- good -->
<a class="skip-link" href="#main">Skip to main content</a>
<header>…</header>
<main id="main" tabindex="-1">…</main>

Źródła

Fakty

Identyfikator
a11y/skip-link
Waga
umiarkowana
Sprawdzanie
w przeglądarce wymaga wyrenderowanej strony: audit --url
Dotyczy plików
page
WCAG 2.2
2.4.1, poziom A
Ten sam problem w
axe-core bypass, axe-core skip-link
Uczy jej skill
fe-a11y-keyboard Keyboard access and focus
Od wersji
0.1.0

Plik reguły na GitHubie

Przeczytaj w terminalu

npx github:dawidolko/frontend-skills explain a11y/skip-link