The tabindexglobal attribute controls whether an element can receive focus and whether it is reached by sequential keyboard navigation (usually the Tab key). An integer value decides the behavior.
Not deprecated and not experimental. Stable global attribute across modern browsers since about July 2015.
Use only 0 and -1.
Per MDN: avoid positive tabindex values (and CSS that reorders focusable items). They make keyboard and assistive-tech navigation harder. Keep focus order matching the document’s logical reading order.
Syntax
HTML Syntax
syntax.html
<element tabindex="integer">
Common safe values: 0 and -1. Equivalent JS: el.tabIndex = 0 (note the capital I in the DOM property).
Values
Attribute Values
Integer values and what they mean:
Value
Description
Try it
0
In Tab order, in document source order (recommended)
One line: use tabindex sparingly — usually 0 or -1, never a handmade positive ladder.
Frequently Asked Questions
It controls whether an element can receive focus and whether it participates in sequential keyboard navigation (usually the Tab key), and can affect relative order among positive values.
MDN recommends using only 0 and -1. Avoid positive values (1, 2, 3…) because they create a confusing custom Tab order that is hard for keyboard and assistive-tech users.
The element is focusable and included in Tab order after any positive tabindex elements, in document source order among other tabindex="0" and naturally focusable controls.
The element can be focused with script (or often a mouse click) but is skipped in sequential Tab navigation. Useful for modals or error messages you focus programmatically.
Usually no. Links with href, buttons, inputs, and similar controls are already in the Tab order. Add tabindex only when you need to change that (for example -1 to remove one from the order).
tabindex alone is not enough for accessibility. Prefer real interactive elements like button or a. Non-interactive tags lack built-in roles and keyboard behavior that assistive tech expects.