Tab order is the sequence in which keyboard focus moves between interactive elements of a web page when a user presses the Tab key, and backward with Shift+Tab. In web accessibility, a correct tab order lets people who cannot use a mouse reach every link, button and form control in a logical, predictable sequence that matches the visual and reading order of the page.
Browsers derive the default order from the DOM source order of focusable elements, and authors can adjust it with the HTML tabindex attribute. The order matters to keyboard users, screen reader users, switch device users and people who navigate with voice commands, and it is evaluated directly by WCAG 2.2 success criterion 2.4.3, Focus Order.
How browsers build the tab order
The browser builds the tab order by walking the document tree and collecting every element that is focusable and not disabled. Natively focusable elements include links with an href attribute, buttons, input, select and textarea fields, summary elements and media controls. Elements that are hidden with display: none, visibility: hidden or the inert attribute are skipped entirely.
The resulting sequence is called sequential focus navigation. When a user presses Tab, focus moves to the next element in that sequence; when focus leaves the last element, it usually moves to the browser interface. Content inside an iframe and inside a shadow root joins the sequence at the position of its host element, so web components keep a predictable place in the order.
The table below summarizes which elements enter the default sequence and under which conditions.
| Element | In default tab order | Condition |
|---|---|---|
| Link (a) | Yes | Only with an href attribute |
| Button | Yes | Unless the disabled attribute is set |
| Form fields | Yes | Unless disabled; radio groups take one stop |
| Summary | Yes | Inside a details element |
| Div or span | No | Requires tabindex=”0″ and a role |
| Element with contenteditable | Yes | Editing host receives focus |
How tabindex values change the sequence
The tabindex attribute is the main tool for adjusting tab order, and its effect depends entirely on the sign of the value. A value of zero adds an element to the natural sequence at its source position, a negative value removes it from sequential navigation while keeping it focusable by script, and a positive value moves it ahead of all other elements.
Positive values are the most common source of broken tab order. Browsers visit every element with tabindex=”1″ first, then tabindex=”2″, and only afterward the elements with zero or no tabindex. On a page with many components, this creates an order that jumps across the layout and becomes almost impossible to maintain.
| Value | Reachable with Tab | Focusable by script | Typical use |
|---|---|---|---|
| Not set | Native elements only | Native elements only | Default for standard controls |
| tabindex=”0″ | Yes, in source order | Yes | Custom widgets built from div or span |
| tabindex=”-1″ | No | Yes | Dialog containers, headings as focus targets |
| tabindex=”1″ or higher | Yes, before all others | Yes | Avoid in almost every case |
The roving tabindex pattern uses these values together. In a toolbar, listbox or tab list, only one item carries tabindex=”0″ and the others carry tabindex=”-1″, so the whole widget becomes a single tab stop and arrow keys move focus inside it. The ARIA Authoring Practices describe the same result with the alternative aria-activedescendant technique.
Tab order compared with related focus concepts
Tab order is one part of a broader keyboard model, and several neighboring concepts in web accessibility are often confused with it. Each one answers a different question about where focus goes and how users perceive it.
| Concept | Question it answers | Relation to tab order |
|---|---|---|
| Tab order | In which sequence does focus move | The baseline sequence itself |
| Focus management | Where should focus go after a change | Moves focus by script outside the sequence |
| Focus indicator | Can users see where focus is | Makes each tab stop visible |
| Focus trap | Can focus leave a region | Limits the sequence to a dialog |
| Skip link | Can users bypass repeated blocks | Adds a shortcut as the first stop |
| Reading order | In which order is content announced | Should match the tab order |
The distinction between tab order and reading order deserves attention. Screen readers read the accessibility tree in DOM order, while sighted users follow the visual layout. When CSS rearranges content, a single source order must serve both, which is why DOM order is the decisive factor for most tab order problems.
Designing a logical tab order
A logical tab order follows the visual reading direction of the page, which is left to right and top to bottom in English layouts and right to left in Arabic or Hebrew. The most reliable way to achieve it is to write the HTML in the intended order and let the browser do the rest, instead of correcting the order afterward with attributes.
- Place the skip link first, followed by the header, main navigation, main content and footer.
- Keep form fields in the order users complete them, with the submit button after the last field.
- Group related controls so that a radio group or tab list counts as one stop.
- Insert dynamic content, such as an error summary or expanded panel, immediately after its trigger in the DOM.
- Remove hidden or offscreen controls from the sequence with inert or display: none.
The following decision table helps choose a correction technique when the order is wrong.
| Situation | Recommended fix | Reason |
|---|---|---|
| Visual order differs from DOM | Reorder the HTML source | Fixes both focus and reading order |
| Custom control is skipped | Add tabindex=”0″ and a role | Joins the natural sequence |
| Closed menu still takes focus | Apply inert or hide it | Removes invisible stops |
| Widget has many stops | Use a roving tabindex | Reduces the number of Tab presses |
| Modal dialog opens | Move focus and trap it | Keeps focus inside the active layer |
Common tab order failures and testing
The most frequent failures come from CSS layout techniques that separate visual and source order. Properties such as order in flexbox, grid-area placement, row-reverse and absolute positioning can move a button to the top of the screen while it remains last in the DOM, so focus appears to jump unpredictably across the page.
Other recurring problems include positive tabindex values left from old templates, clickable div elements without tabindex, offscreen navigation drawers that still receive focus, and cookie banners inserted at the end of the document. Each of these produces either a missing stop, an extra invisible stop or a sequence that contradicts the layout.
Testing tab order requires a manual keyboard pass, because automated tools detect positive tabindex values but cannot judge whether a sequence is logical. Testers press Tab through the whole page, confirm that every interactive element is reached once, that focus is always visible, and that no stop lands on hidden content. Browser developer tools in Firefox and Chrome can display tab order overlays that number each stop and speed up this review.
In plain words
Tab order is the path your keyboard follows through a web page. Each press of the Tab key jumps to the next thing you can use, such as a link, a button or a text box. People who cannot use a mouse rely on this path to do everything on the page.
A good path works like a well-signposted walking route: it moves in the same direction you read and never sends you back and forth. The key point is simple: focus should follow the reading order of the page.
A real-world example
A regional insurance company redesigns its online claim form and uses CSS grid to place a summary panel with a Continue button in the top right corner of the screen. In the HTML, that panel sits after the twelve form fields and the footer links, so keyboard users must press Tab more than 30 times before they reach Continue, passing through the footer on the way.
During an accessibility audit, a tester using only the keyboard reports that focus seems to leave the form and come back. The team moves the summary panel to its logical position in the source, removes two leftover tabindex=”1″ attributes from an older date picker and converts the radio buttons for claim type into one native group.
After the change, the form takes 14 tab stops instead of 33, focus follows the visual layout from top to bottom, and the screen reader announces fields in the same order. The form passes the WCAG 2.2 focus order criterion in the next review, and support calls about incomplete claims from keyboard users stop.