What are skip links and how should they be implemented?
Skip links are an important means of improving the accessibility of a website, especially for users who use keyboard navigation or a screen reader. Here are the most important accessibility aspects that must be considered for skip links:
Accessibility for skip links
- Visibility when focused:
Skip links should not be visible by default, but should become visible as soon as they receive keyboard focus. This makes them easy for keyboard users to find and use. - Clear and understandable labelling:
The link texts should be clear and meaningful, e.g. ‘Skip to main content’ or ‘Skip to navigation’, so that users know immediately where the link leads. - Programmatically set focus:
After activating a skip link, the focus should be programmatically set to the target element (e.g. main content) so that users can jump directly there and start interacting. - Target elements with unique IDs:
The targets of skip links must be assigned unique IDs so that the skip link works accurately. - Skip links should be at the top of the page:
To ensure that keyboard users reach the skip links first, they should be placed at the top of the source code if possible. - No unexpected context changes:
The jump must not cause any disruptive or unexpected changes in the page context that could confuse users.
Code Example:
<a href="#maincontent" class="skip-link">Skip to main content</a>
<!-- ... at the top of the page ... -->
<main id="maincontent" tabindex="-1">
<!-- Main content of the page -->
</main>
Explanation:
The link with href="#maincontent" jumps directly to the element with the ID maincontent.
The target element (here <main>
) has a tabindex="-1"
so that it can receive focus programmatically when the jump link is activated. This is important so that screen reader users or keyboard users are taken directly to the target.
The skip-link
class is often used to make the link visually visible only when focused (e.g. with CSS :focus
) so that it is not constantly in the field of vision but remains easily accessible.
CSS example
Here is a simple CSS example that makes a skip link visible only when it is focused via the keyboard. This keeps the link accessible for screen reader and keyboard users, but does not interfere with the visual design for mouse users:
.skip-link {
position: absolute;
top: -40px; /* Link initially outside the visible area */
left: 0;
background: #000;
color: #fff;
padding: 8px 16px;
z-index: 100;
transition: top 0.3s ease;
text-decoration: none;
}
.skip-link:focus {
top: 0; /* Link slides into the visible area when focusing */
outline: 2px solid #fff;
}
How this works:
- By default, the link is positioned at the top outside the screen (
top: -40px
). - As soon as the link is focused using the keyboard (
:focus
), it becomes visible by moving down totop: 0
. - This ensures that users navigating with the keyboard can see and use the skip link.
- The
outline
makes the focus clearly visible.