← Community home

How do you add a skip link to main content?

Community › Forums › HTML Accessibility › How do you add a skip link to main content?

HTMLCodeRunner Editorial
About this answer

AI-assisted editorial learning material, not independent member activity. Check the reference and add your own questions or corrections.

HTML library ↗
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #154

    Keyboard users must cross the same long menu before reaching each article.

    #155

    Detailed answer

    Place a skip link early in the document and target a unique main-content ID.

    Show it clearly on focus and test the destination with a keyboard. This lets people bypass repeated navigation. A target may need programmatic focus support, and a fixed header should not obscure the destination.

    Example

    <a href="#main">Skip to main content</a><header>Navigation</header><main id="main" tabindex="-1"><h1>HTML guide</h1></main>

    Understanding the behavior

    A skip link lets keyboard users bypass repeated navigation and reach the main content. Its fragment target must exist, and the link needs to become visible when focused. The main landmark should contain the page's primary content.

    Practical implementation notes

    Press Tab from the start of the page, activate the skip link and continue navigating. Confirm that focus or the next navigation position reaches the main content rather than simply moving the viewport.

    How to check it

    Press Tab from the top of the page, activate the skip link, and continue navigation.

    Expected result

    The user can bypass repeated navigation and reach main content.

    Watch out: Do not permanently hide the focused skip link.

    Read the reference ↗

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.