HTML Guide
The tabindex
attribute expects a valid integer value, not an empty string.
This attribute allows developers to make HTML elements focusable, allow or prevent them from being sequentially focusable (usually with the Tab key) and determine their relative ordering for sequential focus navigation.
This attribute accepts an integer value, where:
- A negative value means the element is not reachable via sequential keyboard navigation.
-
A value of
0
means that the element should be focusable in sequential keyboard navigation, after any positivetabindex
values. The focus navigation order of these elements is defined by their order in the document source. -
A positive value means the element should be focusable in sequential keyboard navigation, with its order defined by the value of the number. That is,
tabindex="4"
is focused beforetabindex="5"
andtabindex="0"
, but aftertabindex="3"
.
Learn more:
Related W3C validator issues
An <a> element cannot contain a descendant element with the attribute tabindex.
A button element cannot contain a descendant element with the attribute tabindex.