Glossary · Accessibility term
Tabindex
Tabindex is an HTML attribute that decides whether an element can take keyboard focus and where it sits in the tab order. A value of 0 puts an element into the natural order, which follows the source. A value of -1 makes it focusable by script, and by a mouse click, while skipping it when tabbing, which is how you move focus to a heading or to an error message. Anything positive is the documented anti-pattern. Positive values go first, ahead of everything set to 0 or to nothing at all, and they run lowest number first, so a single stray tabindex="3" reorders everything around it. Every element added afterwards then has to be reasoned about against a custom order somebody left behind. Treat them as a bug, not a tool.
In practice
The most common real mistake is tabindex="0" on a <div> that was meant to act like a button. It makes the div reachable and it does not make it a button. Its role is still generic, so no button semantics, no Enter or Space handling, no state, and nothing in the accessibility tree saying it does anything. A native button gives you all of that and needs no attribute at all. It does not give you a name for free, though. That comes from the text inside it, so a button holding nothing but an icon is still yours to label.
The same failure now arrives far more often by a different route, through CSS. Reordering flex items or placing grid items changes what you see, and the tab order follows the source. So the visual order and the focus order come apart with no tabindex anywhere in the file. If a page tabs in a strange order and nobody wrote a positive value, look at the layout.
Two attributes take elements out of the focus order entirely, and both are useful to know. A disabled control cannot be tabbed to at all, which is worth remembering because a keyboard user cannot even reach it to find out why it is off. And the inert attribute removes a whole region, which is the correct modern fix for focus escaping behind a modal.
One detail that surprises people debugging focus. The exact negative value does not matter, so -1 and -99 behave identically, and on the usual desktop browsers an element with a negative tabindex can still take focus from a mouse click. Script is the intended route rather than the only one, and platform conventions differ, so check rather than assume.
Why it matters
WCAG never mentions tabindex in any criterion. What gets tested is the order a user actually gets and whether it preserves meaning and operability, which cuts both ways. A positive value is not automatically a failure if the resulting order still makes sense, and a page with no tabindex anywhere can fail badly. Write the finding against the order, not the attribute, because the fix for a control that is not keyboard accessible is nearly always a different element rather than another attribute.
The check
Tab through a page and watch where focus goes. If it jumps somewhere unexpected, search the codebase for a positive tabindex first. If there is not one, look at your flex and grid ordering instead. Both produce exactly the same complaint, and only one of them is visible in the markup.
Where this shows up on the site
Related terms
- FocusFocus is the one place on a page that is currently taking keyboard input.
- Focus orderFocus order is the sequence focus travels in as you press Tab, and by default it follows the order elements appear in the code rather than the order they appear on screen.
- Keyboard accessibilityKeyboard accessibility means every piece of functionality on the page can be operated through a keyboard interface.
- Semantic HTMLSemantic HTML means using HTML elements for what they mean rather than for how they look.
- ARIAARIA is a set of attributes that tell assistive technology what a custom control is and what state it is in.
Knowing the word is the easy part.
Find out where your own site stands. The free scan checks 10 pages in a real browser against all 90 supported automated rules, separates 27 best-practice checks from its WCAG findings, and names the rule behind every result.