Keyboard Focus Trap & Tab Order Simulator

Visualize keyboard tab order, inspect focusable elements, and test modal focus-trap behavior from pasted HTML.

Web Accessibility Local processing Pasted HTML is analyzed locally.

Simulator

Leave empty to analyze the entire pasted HTML. Use a selector to simulate a modal or dialog focus trap.

Results

Paste HTML and run the keyboard audit.

Simulated focus

No simulated focus. Use Next Tab or Previous Tab to begin.

Tab order

    Introduction

    Keyboard accessibility depends on a predictable focus order. Menus, dialogs, forms, and custom widgets can easily break tab order when they misuse tabindex or fail to trap focus correctly.

    This tool helps you inspect the focusable elements in a block of HTML and simulate the approximate tab sequence before testing in a live environment.

    How it works

    The tool parses pasted HTML inside an inert template element. It then finds focusable elements, filters out disabled and hidden controls, and sorts the approximate tab order based on tabindex and DOM order.

    • Scripts in pasted HTML are not executed.
    • Dangerous elements such as script and iframe are removed.
    • Positive tabindex values are sorted before natural order.
    • Negative tabindex values are excluded from tab order.

    How to use

    1. Paste HTML.
    2. Optionally enter a container selector for a modal or dialog.
    3. Click Audit HTML.
    4. Review messages and the generated tab order.
    5. Use Next Tab and Previous Tab to simulate keyboard focus.
    6. Copy the report or focus-trap snippet.

    Practical example

    A dialog should usually contain at least one tabbable element, trap Tab and Shift+Tab, and return focus to the trigger when closed. This tool can help you check whether the dialog markup contains focusable controls and whether the tab order looks reasonable.

    Use cases

    • Reviewing modal markup before implementing JavaScript.
    • Finding accidental positive tabindex values.
    • Checking whether custom controls are keyboard reachable.
    • Debugging focus order in forms and navigation menus.
    • Preparing accessibility test notes.

    Best practices

    • Prefer native interactive elements over focusable divs.
    • Avoid positive tabindex values.
    • Use tabindex="-1" only for programmatic focus.
    • Trap focus inside modal dialogs while they are open.
    • Return focus to the opening element when a dialog closes.

    Common mistakes

    • Adding tabindex="0" to static text without keyboard behavior.
    • Using positive tabindex to reorder focus.
    • Leaving background content tabbable while a modal is open.
    • Making an element focusable without an accessible role or label.
    • Forgetting to test Shift+Tab.

    Limitations

    • The simulator uses static HTML and cannot fully evaluate rendered CSS visibility.
    • JavaScript-driven focus changes are not simulated.
    • Shadow DOM content is not analyzed.
    • Real focus behavior should always be verified with a keyboard.

    Browser compatibility

    The tool itself works in current versions of major browsers. The keyboard patterns it checks are based on widely supported HTML and ARIA behavior.

    FAQ

    Is my HTML uploaded?

    No. The HTML is parsed and analyzed locally in your browser.

    Does it execute scripts from pasted HTML?

    No. Pasted HTML is placed into an inert template and dangerous elements are removed.

    Is positive tabindex always wrong?

    It can be valid in rare cases, but it often creates unpredictable keyboard order. Most interfaces should rely on natural DOM order and tabindex="0".

    Does this prove my modal is accessible?

    No. It helps identify common issues, but modal accessibility also requires live focus management, Escape handling, labeling, and focus restoration.

    References

    Version and changelog

    • Version: 1.0.0
    • Last updated: August 8, 2026
    • Changelog: Initial production release.