← Community home

When should tabindex be zero or minus one?

Community › Forums › HTML Accessibility › When should tabindex be zero or minus one?

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
  • #158

    You need to move focus to a heading without adding another ordinary Tab stop.

    #159

    Detailed answer

    Zero places an appropriate element in normal sequential focus order.

    Minus one permits programmatic focus without an ordinary Tab stop. Native interactive controls already participate in focus navigation. Positive values can conflict with visual and document order and are best avoided. Keep extra focus stops limited to meaningful interaction needs.

    Example

    <main id="main" tabindex="-1"><h1>Lesson</h1></main>

    Understanding the behavior

    Tabindex=0 joins the normal sequential focus order, while -1 generally permits programmatic focus without joining that sequence. Positive values create a separate ordering that can become confusing as a page changes. Native interactive elements often need no tabindex.

    Practical implementation notes

    Follow the page with Tab and Shift+Tab. The focus order should match a sensible reading order. Removing a control from the tab sequence does not automatically hide it from assistive technology.

    How to check it

    Use tabindex=-1 for the programmatic destination and inspect the natural Tab sequence.

    Expected result

    The heading can receive managed focus without cluttering sequential navigation.

    Watch out: Do not add a Tab stop to every paragraph or decoration.

    Read the reference ↗

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