A skip link is often the first keyboard-focusable item on a page. It gives keyboard users a direct route past repeated menus to the main content. The important question is always where the link leads and whether the person reading the page can predict it.
What You Need to Know
The destination needs a real id; tabindex="-1" can let scripts or focus navigation target a normally nonfocusable main element. CSS should reveal the link on focus.
Links are the pathways through a website. The words on a link should help someone choose where to go before clicking it.
Example: See It in Action
Add this example to the appropriate part of a practice HTML page. Read each line before you open the page in your browser.
This is a short HTML fragment. To try it as a webpage, put it inside the body element of a complete HTML document.
<a class="skip-link" href="#main-content">Skip to main content</a>
<nav aria-label="Main menu"><a href="index.html">Home</a>
</nav>
<main id="main-content" tabindex="-1">
<h1>Welcome!</h1>
</main>
Let’s Understand the Example
- An a element becomes a working link when it has an href. Its visible text should tell readers where they will go.
- Nav identifies a major collection of navigation links.
- Main identifies the central content of the page; it should not be duplicated as separate visible main landmarks.
- Class is a reusable label for styling or scripts; several elements may share the same class.
- Href contains the destination of a link. A value starting with # points to an id on the same page.
- Aria-label supplies an accessible name when a visible label is unavailable or inadequate.
The first example link points to #main-content. Check whether that destination exists relative to the document. A link changes where readers go; it does not perform an action such as saving a form.
What Should You See?
You should see a link named “Skip to main content”. Selecting it leads to #main-content when that destination exists. Try it with the mouse and the keyboard.
Imagine this link is read out of context. Would its text still explain the destination? Rename unclear links before trying to make them look nicer with CSS.
Try It Yourself
- Use the Tab key from the top of the page to reach the skip link.
- Save your changes, open or refresh the page, and compare the result with the original example.
- Tell a friend what your change did. If you are not sure, undo it, refresh the page, and compare.
Common Beginner Mistakes
- Using href="#main-content" when the page contains no matching id.
- Avoid dead links, empty href values and clickable-looking text without a real destination.
Key Takeaways
- A skip link is often the first keyboard-focusable item on a page.
- An a element becomes a working link when it has an href. Its visible text should tell readers where they will go.
- The destination needs a real id; tabindex="-1" can let scripts or focus navigation target a normally nonfocusable main element. CSS should reveal the link on focus.