Tab Order Visualizer
Paste any HTML snippet and this tool computes the exact keyboard tab sequence a user would follow. It applies the WCAG focus-order algorithm: positive tabindex elements come first (ascending), then natural DOM order. Elements with tabindex=-1 are listed separately as script-focusable only. Anti-patterns like positive tabindex values and focusable elements with no accessible name are flagged so you can fix them before users encounter them.
How to use the Tab Order Visualizer
Paste the HTML of a form, modal, or page section into the text area and click Visualize Tab Order. The tool will:
- Parse the HTML safely with
DOMParser(nothing is injected into the live page). - Collect all natively focusable elements:
<a href>,<button>,<input>,<select>,<textarea>(not disabled, not hidden), and any element with atabindexattribute. - Sort them by the WCAG tab-order rule: elements with a positive
tabindexcome first (sorted numerically, DOM order breaks ties), then the rest follow natural document order (tabindex=0 or absent). - Elements with
tabindex=-1are excluded from the tab sequence but listed at the bottom as "script-focusable only".
The result shows a numbered sequence with each element's tag, id/name, and accessible name (derived from aria-label, associated <label>, alt, placeholder, or text content). Anti-patterns — positive tabindex values and focusable elements with no accessible name — are flagged in red with a suggested fix.
Tab order and why it breaks
The keyboard tab order is the sequence in which interactive elements receive focus when a user presses Tab. It is determined by the browser following a two-stage algorithm defined in the HTML specification: first, any element with a positive integer tabindex (1, 2, 3…) is visited in ascending numeric order; then all elements with tabindex="0" or no tabindex are visited in the order they appear in the DOM. Elements with tabindex="-1" are excluded from this sequence entirely — they can only receive focus via JavaScript (el.focus()), which is useful for custom widgets.
The most common anti-pattern is using positive tabindex values (e.g. tabindex="3") to "fix" a broken visual layout. This creates a maintenance nightmare: every time the page changes, the manual sequence must be re-audited. A far better approach is to fix the source order in the HTML to match the intended reading/interaction order, and then let the browser's natural algorithm do the right thing. WCAG 2.1 Success Criterion 2.4.3 (Focus Order) requires that the focus sequence preserve meaning and operability — a mis-ordered tab sequence is a Level A accessibility failure.
A second common failure is a focusable element with no accessible name — for example, an icon-only <button><img src="x.png"></button> with no alt, no aria-label, and no visible text. Screen readers will announce this as "button" with no description, leaving keyboard users unable to understand the control's purpose. WCAG 2.4.6 and 4.1.2 both address this.
Common use cases
- Accessibility audits — confirm the tab sequence matches the visual reading order before submitting to WCAG or VPAT reviews.
- Form review — catch inputs that are accidentally skipped (disabled by mistake) or arrive out of order due to CSS positioning tricks.
- Modal / dialog QA — verify that focus is trapped inside a dialog and that all interactive controls inside are reachable.
- Refactoring legacy HTML — discover lurking
tabindexvalues left behind from an older layout, which can silently break keyboard navigation. - Component library review — paste a rendered component template and verify its internal focus management before merging.