When should I use tabindex values on website elements?
Quick answer
Most of the time, do not add tabindex to native controls such as links with href, buttons, and form fields; they are normally keyboard-focusable already. Use tabindex="0" when a non-interactive element genuinely needs to join normal Tab navigation, and tabindex="-1" when it should be focusable by code but skipped by Tab. Avoid positive values: they create a separate numeric order that can be confusing when the page changes. [S1]
The question, the details, the next step.
A practical checklist
Identify whether the element is already a native link or form control.
Use tabindex="0" only when an element needs normal sequential Tab access.
Use tabindex="-1" only when programmatic focus is intended without a Tab stop.
Replace positive tabindex values with a logical document-order approach where possible.
Test the complete keyboard interaction, not just the presence of a focusable element.
A few more useful answers
Does tabindex="0" make a div into a button?
No. It makes the element sequentially focusable according to its document position, but does not by itself give it button behavior. [S1]
Should I add tabindex="0" to every link and button?
Usually not. Links with href and native buttons are normally focusable without adding tabindex. [S1]
What does a negative tabindex do?
A negative value allows programmatic focus without adding the element to sequential Tab navigation. [S1]
Sources
References used for this guide.
- [S1] MDN: tabindex global attribute developer.mozilla.org · Checked
