tabindex
The tabindex global attribute allows developers to make HTML elements focusable, allow or prevent them from being sequentially focusable (usually with the Tab key, hence the name) and determine their relative ordering for sequential focus navigation.
Browser support
| Feature | Desktop | Mobile | ||||
|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Safari | Chrome Android | Safari iOS | |
| 1 | 12 | 1.5 | 3.1 | 18 | 2 | |
| DOM API | ||||||
| The tabIndex property of the HTMLElement interface represents the tab order of the current element. | 1 | 18 | 1 | 3.1 | 18 | 2 |
1+Supported (version) Not supported ※Has note Sub-feature descriptions sourced from MDN Web Docs (CC BY-SA 2.5)
Notes 3 item(s)
Limitation
- This browser only partially implements this feature
Removed
- This feature was removed in a later browser version (18)
Implementation note
- Returns incorrect value for elements without an explicit tabindex attribute. See issue 4365703 for details.
Syntax
HTML
<!-- make focusable (included in tab order) --> <div tabindex="0" role="button">custom button</div> <!-- focusable only from program --> <div tabindex="-1" id="notification">notification area</div> <!-- order specified with tabindex="0" or higher (deprecated) --> <input tabindex="1"> <input tabindex="2"> Live demo
Tab ki-. ordercontrol
ki-bo-dnavigation. order and focuspossible control. with tabindex
PreviewFullscreen
Use cases
-
Custom interactive surfaces
Make a custom card, menu item, or disclosure trigger keyboard-focusable when native elements are not available.
-
Programmatic focus management
Move focus to an alert, heading, or dialog section with tabindex='-1' when the UI state changes significantly.
Cautions
- Positive tabindex values create a manual focus order that is hard to maintain and often disagrees with the DOM order.
- If an element is focusable, it usually also needs keyboard behavior and an accessible role or native semantics.
Accessibility
- Prefer native buttons, links, and form controls first. Custom focusable elements need much more supporting work.
- Keep the DOM order aligned with the visual order so keyboard and screen reader navigation stay predictable.