HTML Snippet

Accessible Skip-to-Content Link

Difficulty: Easy

A skip-to-content link lets keyboard and screen-reader users jump past the navigation straight to the main content. Most sites get the markup right but hide it permanently with `display: none`, which screen readers also skip. This snippet covers the visually-hidden-until-focus pattern, the matching CSS to keep it usable, and the required `<main>` target so the link actually works.

Code Snippets
/

Accessible Skip-to-Content Link

Accessible Skip-to-Content Link

A skip-to-content link lets keyboard and screen-reader users jump past the navigation straight to the main content. Most sites get the markup right but hide it permanently with `display: none`, which screen readers also skip. This snippet covers the visually-hidden-until-focus pattern, the matching CSS to keep it usable, and the required `<main>` target so the link actually works.

HTML
Easy
3 snippets
html-elements
accessibility
html-accessibility
code-template

989 views

13

The skip link is the very first focusable element on the page so a Tab press from the address bar lands on it before any nav links. The href="#main" jumps focus and scroll to a target with id="main", which is the <main> landmark. Adding tabindex="-1" to <main> makes it programmatically focusable so screen readers actually move focus there (some browsers skip the focus jump otherwise). This combination is the W3C-recommended pattern for skip links.