HTMLElement.tabIndex

The tabIndex property of the HTMLElement interface represents the tab order of the current element.

Tab order is as follows:

  1. Elements with a positive tabIndex. Elements that have identical tabIndex values should be navigated in the order they appear. Navigation proceeds from the lowest tabIndex to the highest tabIndex.
  2. Elements that do not support the tabIndex attribute or support it and assign tabIndex to 0, 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

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

© 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