DevTools Logo

Focus Order & Tab Flow Visualizer

Focus Order & Tab Flow Visualizer

Paste HTML to see computed keyboard tab order, focus anomalies and tabindex anti-patterns.

Runs in your browser
Try an example

HTML to inspect

Computed tab order

Paste HTML to inspect its tab order

Scripts and network resources are stripped before rendering.

Details

Keyboard navigation bugs are hard to infer from markup. Paste an HTML snippet and this tool lists every focusable element in the order a browser would tab through it: positive tabindex values first in ascending order, then natural DOM order. Hidden, disabled, inert and negative-tabindex elements are listed separately with the reason they were excluded. Anti-pattern checks flag positive tabindex chains, aria-hidden on focusable elements, duplicate ids and scroll-container focus styles, each with a plain-language fix. The preview is rendered in a sandboxed iframe with scripts and external resources stripped, so only static markup is analyzed — JavaScript-driven order changes and shadow-root contents are outside scope. Step forward or backward through the sequence and export the findings as Markdown for a ticket.

More examples

Modal audit

<div role="dialog">
  <button tabindex="3">Save</button>
  <button aria-hidden="true">Close</button>
  <button>Cancel</button>
</div>

Save hijacks the order and Close is focusable but silenced; both are flagged with fixes.

Hidden menu

<div style="display:none"><button>Hidden</button></div>
<button>Visible</button>

The hidden item is excluded and listed with the reason, so the visible button is step 1.

Reverse traversal

Step through: A → B → C
Reverse: C → B → A

Shift+Tab-style stepping often reveals order regressions that forward tabbing hides.

    Examples

    Positive tabindex

    Input
    <a href="/two" tabindex="1">Two</a><a href="/one">One</a>
    Output
    1. Two · 2. One

    The positive value jumps ahead of markup order.

    Silenced button

    Input
    <div aria-hidden="true"><button>Close</button></div>
    Output
    error: aria-hidden on focusable

    Keyboard and screen-reader experiences diverge.

    Hidden item

    Input
    <div style="display:none"><button>Hidden</button></div>
    Output
    Excluded: hidden by display:none

    Invisible controls cannot be tabbed to.

    About this tool

    Focus Order & Tab Flow Visualizer computes the keyboard tab sequence for a pasted HTML snippet. Focusable elements are numbered in browser order: positive tabindex values first, then natural DOM order, with hidden, disabled, inert and negative-tabindex elements listed separately.

    The anti-pattern pass flags positive tabindex chains, focusable elements inside aria-hidden subtrees, duplicate ids and scrollable containers without visible focus treatment. Each finding carries a fix you can paste into a ticket.

    Markup is sanitized and rendered in a sandboxed iframe with a restrictive content-security policy and no external resources. Only static order is analyzed — JavaScript-driven focus changes and shadow-root contents are outside scope.

    What this tool does not do

    • Only static, sanitized markup is analyzed; JavaScript-shown elements and shadow roots are not reflected.
    • Browser focusability differs at the edges; the conservative selector may disagree with an exotic engine.
    • The preview cannot fetch external stylesheets or images, so layout-dependent behavior is not reproduced.
    • Wrap-around focus traps in scripted modals are not detected; reverse stepping is an aid, not proof.

    How to use this tool

    1. Paste markup

      Use a component snippet, modal or full page body; scripts and event handlers are stripped automatically.

    2. Read the numbered order

      Each badge shows the element and why it appears in that position; click one for its tabindex and inclusion reason.

    3. Review findings

      Errors, warnings and notes include plain-language fixes for tabindex and aria-hidden problems.

    4. Step and export

      Simulate Tab or reverse traversal, then copy the Markdown report into your accessibility ticket.

    Use cases

    Modal reviews

    Check close/save/cancel order before shipping a dialog.

    Design systems

    Verify that widget tabindex patterns do not hijack page order.

    Ticket evidence

    Export a Markdown sequence and findings for an accessibility bug report.

    Ordering rules

    Element stateTab position
    tabindex="2"First group
    tabindex="0" or nativeDOM order
    tabindex="-1"Excluded
    display:none / hidden / inertExcluded
    aria-hidden ancestorIncluded + error

    The preview iframe has no scripts and cannot fetch subresources.

    Common mistakes

    Mistake:Using positive tabindex to match visual order.

    Fix:Reorder the DOM instead; positive values affect the whole document.

    Mistake:Putting aria-hidden on a focusable control.

    Fix:Remove aria-hidden from the control or take it out of the tab order.

    Mistake:Assuming JavaScript-driven focus changes are analyzed.

    Fix:Scripts are stripped; test dynamic widgets in a real browser too.

    Mistake:Ignoring excluded elements.

    Fix:Review the excluded list — a control hidden by CSS may still be needed.

    Frequently asked questions

    How is tab order computed?

    Elements with positive tabindex come first in ascending numeric order, followed by naturally focusable elements in DOM order. Negative tabindex, disabled, hidden, inert and contenteditable=false elements are excluded and listed with the reason.

    Why is my button skipped?

    Check the Excluded list. Common causes are a hidden or inert ancestor, display:none from inline style, a disabled control or ancestor fieldset, or tabindex="-1" which makes the element script-focusable but not part of the Tab sequence.

    Are positive tabindex values always wrong?

    In almost every page-level case, yes. A positive value inserts an element into a global order that is hard to maintain and ignores document flow. Reorder the markup so natural DOM order matches the visual order instead.

    Does the preview run scripts from my HTML?

    No. Scripts, event handlers and javascript: URLs are stripped, external subresources are blocked by a content-security policy, and the iframe runs without allow-scripts.

    Can it detect focus traps in JavaScript modals?

    Not fully. The tool detects static anti-patterns and lets you step forward and backward through the declared order, but wrap-around logic implemented in scripts must be verified in a real browser.

    Is my pasted HTML uploaded?

    No. Sanitization, analysis and the sandboxed preview all happen in your browser tab; nothing is sent over the network.

    References & standards