HTMLElement.tabIndex
The tabIndex property of the HTMLElement interface represents the tab order of the current element.
Tab order is as follows:
- Elements with a positive
tabIndex. Elements that have identicaltabIndexvalues should be navigated in the order they appear. Navigation proceeds from the lowesttabIndexto the highesttabIndex. - Elements that do not support the
tabIndexattribute or support it and assigntabIndexto0, in the order they appear.
Elements that are disabled do not participate in the tabbing order.
Values don't need to be sequential, nor must they begin with any particular value. They may even be negative, though each browser trims very large values.
Syntax
element.tabIndex = index; var index = element.tabIndex;
Value
index is an integer
Example
const b1 = document.getElementById('button1'); b1.tabIndex = 1;
Specifications
| Specification |
|---|
| HTML Standard (HTML) # dom-tabindex |
Browser compatibility
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
tabIndex |
1 |
18
12
Returns incorrect value for elements without an explicit tabindex attribute. See issue 4365703 for details.
|
1 |
5.5
Returns incorrect value for elements without an explicit tabindex attribute. See issue 4365703 for details.
|
≤12.1 |
3.1 |
4.4 |
18 |
4 |
≤12.1 |
2 |
1.0 |
See also
- Accessibility of keyboard-navigable JavaScript widgets
- The HTML
tabindexglobal attribute.
© 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/tabIndex