Menu
CoddyTech

Keyboard Skip Links

Part of the Responsive UI Patterns section of Coddy's Tailwind CSS journey. Lesson 9 of 55.

A skip link lets keyboard users bypass repeated navigation. Place it before the navigation and point its fragment href to the content ID. A target with tabindex="-1" can receive focus without adding another stop to ordinary Tab order.

<a href="#search" class="sr-only focus:not-sr-only">Skip to search</a>
<main id="search" tabindex="-1">Search books</main>

The sr-only utility visually hides an element using a small clipped absolute box without removing it from accessible content. not-sr-only reverses that pattern. Apply the inverse with focus: so a keyboard user can see the link when it becomes active.

The example targets a library search region. Keep the real anchor and target semantics, then verify a keyboard journey from the beginning of the page. Changing display alone does not undo the clipping and one-pixel dimensions.

challenge icon

Challenge

Medium

Keep the first skip link visually hidden with the accessible screen-reader pattern until it receives focus. On focus, restore its ordinary position, dimensions, unclipped content and wrapping. Preserve its sessions destination and the focusable main target.

Preserve the supplied content, semantic elements and IDs. Edit the requested utility classes. Press Run preview after edits, then Check/Run code to grade the result. Supplied JavaScript is read-only.

Try it yourself

<!doctype html>
<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Interface workshop</title><link rel="stylesheet" href="./styles.css"></head><body>
<a id="skip" href="#content" class="sr-only">Skip to sessions</a><nav aria-label="Primary"><a href="#home">Home</a></nav><main id="content" tabindex="-1">Sessions</main>
</body></html>
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Responsive UI Patterns