CKTIS / JavaScript
HTMLElement.tabIndex — focus and navigation order
The tabIndex property reflects the tabindex attribute and influences focusability and keyboard navigation order.
Version: ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support
Syntax
element.tabIndex;
element.tabIndex = integer;HTMLElement.tabIndex reads an integer; assignment writes the tabindex attribute. Without a valid value, the default reading depends on the element: 0 for button, but -1 for div.
0 requests inclusion in the normal Tab order but does not guarantee a Tab stop. A negative value normally leaves the element out of that order without preventing focus() from focusing it if it is otherwise able to receive focus. Neither setting makes an inert or non-rendered element, or a disabled form control, focusable. User preferences can also affect Tab navigation. Positive values establish priority within a navigation scope; prefer 0 and -1.
The reading alone does not prove focusability. Assigning -1 does not remove the attribute; use removeAttribute('tabindex').
Examples
const element = document.createElement('div');
const report = () => console.log(JSON.stringify([
element.tabIndex,
element.getAttribute('tabindex')
]));
report();
element.tabIndex = 0;
report();
element.tabIndex = -1;
report();
element.removeAttribute('tabindex');
report();Result
[-1,null] [0,"0"] [-1,"-1"] [-1,null]
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.