Skip Link
| Property | Value |
|---|---|
| ID | skip-link |
| Severity | Warning / Error |
| WCAG | 2.4.1 Bypass Blocks |
What it checks
Looks for a skip-navigation pattern and checks that activation takes keyboard users to the link's target.
How it works
Keylens uses two detection methods, preferring the functional test when available:
Functional Test (crawler)
Before the main tab crawl, the crawler:
- Tabs through the first 5 focusable elements
- Checks each element against skip link patterns (e.g., "skip to content", "jump to main"). Only a same-page
<a href="#…">link is probed; a purchase button or a link to another page is never activated. - If found, presses Enter on the skip link. If a handler navigates away, the crawler returns to the audited page.
- Records where focus went. When focus stays on the link (or resets to the body), as it does for a native jump to a non-focusable target, the crawler presses Tab once and checks that focus lands inside the target. A prevented or no-op jump fails because Tab goes to the next control instead.
Results:
- Skip link found and focus moves to, or the next Tab lands inside, the target → Pass
- Skip link found but activation does not lead into the target → Error
- No skip link found → Warning
Heuristic Fallback
When the functional test is not available, the rule scans the first 5 elements in the focus sequence for skip link patterns in their accessible name or HTML.
When focus moves directly, the check does not prove the destination matches the link's fragment; confirm the recorded target manually.
Skip Link Patterns
The following regex patterns are matched against element text and HTML:
skip.*(?:nav|content|main)jump.*(?:nav|content|main)go.*to.*(?:content|main)skip.*to
Examples
Pass
html
<a href="#main-content" class="skip-link">Skip to main content</a>
<!-- ... navigation ... -->
<main id="main-content" tabindex="-1">
<!-- main content -->
</main>Fail (missing)
html
<!-- No skip link at all -->
<nav>
<a href="/home">Home</a>
<a href="/about">About</a>
<!-- 20 more nav links... -->
</nav>Potentially broken
html
<!-- Skip link points to non-existent target -->
<a href="#content" class="skip-link">Skip to content</a>
<main id="main-content"><!-- wrong ID --></main>The functional check can still pass this example if a script moves focus to some other element. Confirm the recorded target manually.
How to fix
- Add a skip link as the first focusable element on the page
- Point it to the main content area via an
hreffragment (#main-content) - Ensure the target element has
tabindex="-1"so it can receive focus programmatically - The skip link can be visually hidden until focused using CSS