Lesson 9 of 30
A mouse user reaches the main content of any page in one click, no matter how big the navigation is. Without a bypass mechanism, a keyboard user has to Tab through every single nav link first, on every single page.
10 min read
Every option explains itself — why the right one is right, and why each wrong one is wrong. Miss one and it comes back later on a spaced-repetition schedule.
Question 1 of 3
A skip link points to `href="#main-content"`, and `<main id="main-content">` has no `tabindex` attribute. What happens when a keyboard user activates the skip link and then presses Tab again?
Hints without spoilers, and a plain explanation of why a wrong answer was wrong — answered only from this lesson. Free account, no card.
Sign up freeWhat interviewers actually ask about this, and what a strong answer has to cover.
A strong answer covers
Likely follow-ups
Most pages put a header with a navigation menu — often a dozen or more links — before the actual content a user came for. A mouse user never notices this cost: they click wherever they want, instantly. A keyboard user pays it every time: without a bypass mechanism, reaching the main content means pressing Tab through every single navigation link first, and doing it again on every page of the site, since the same header repeats everywhere. This is a real, tedious, completely avoidable barrier — not a hypothetical edge case.
A skip link solves it. It's a link, typically the very first focusable element on the page, reading something like "Skip to main content." Its defining behavior is that it's visually hidden by default and becomes visible only when it receives keyboard focus — so it doesn't clutter the design for sighted mouse users, but it's the very first thing a keyboard user encounters when they start tabbing. Activating it jumps focus straight past the repeated navigation into the main content region.
<body>
<a href="#main-content" class="skip-link">Skip to main content</a>
<header>
<nav><!-- a dozen navigation links --></nav>
</header>
<main id="main-content" tabindex="-1">
<h1>Page content starts here</h1>
</main>
</body>
.skip-link {
position: absolute;
top: -40px; /* off-screen by default */
left: 0;
}
.skip-link:focus {
top: 0; /* moves on-screen the moment it receives keyboard focus */
}
The CSS pattern here is standard and correct: absolutely position the link off-screen, then use a :focus style to bring it on-screen exactly when it's needed. But the detail people get wrong is on the <main> element itself — tabindex="-1". Without it, clicking the skip link scrolls the page down to #main-content (the browser's normal same-page anchor behavior) but doesn't actually move keyboard focus there, because <main> isn't a naturally focusable element. A user who activates the skip link and then presses Tab again would land back near the top of the page, inside the navigation they just tried to skip — the link visually "worked" but the actual keyboard-navigation problem it exists to solve is still unsolved.
tabindex="-1" on the target isn't there to add it to the tab order — it's specifically so that JavaScript- or anchor-driven focus-setting works on an element that isn't naturally focusable. The element still won't appear when tabbing through the page normally; it's reachable only via the skip link's jump.display: none or visibility: hidden instead of off-screen positioning removes it from the accessibility tree entirely, which defeats the purpose — it needs to be present and focusable at all times, just not visible until focused."This page has 40 nav links before the content — what would you add, and what's the one implementation detail people usually get wrong?" is a real, specific question, and naming tabindex="-1" on the jump target — not just "add a skip link" — is what shows you've actually tested one rather than just read about the pattern.