docs.rodeo

MDN Web Docs mirror

tabindex

{{HTMLSidebar("Global_attributes")}} 

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.

{{EmbedInteractiveExample("pages/tabbed/attribute-tabindex.html","tabbed-standard")}} 

It accepts an integer as a value, with different results depending on the integer’s value:

[!NOTE] If an HTML element renders and has tabindex attribute with any valid integer value, the element can be focused with JavaScript (by calling the focus() method) or visually by clicking with the mouse. The particular tabindex value controls whether the element is tabbable (i.e. reachable via sequential keyboard navigation, usually with the Tab key).

Some focusable HTML elements have a default tabindex value of 0 set under the hood by the user agent. These elements are an {{HTMLElement("a")}}  or {{HTMLElement("area")}}  with href attribute, {{HTMLElement("button")}} , {{HTMLElement("frame")}}  {{deprecated_inline}} , {{HTMLElement("iframe")}} , {{HTMLElement("input")}} , {{HTMLElement("object")}} , {{HTMLElement("select")}} , {{HTMLElement("textarea")}} , and SVG {{SVGElement("a")}}  element, or a {{HTMLElement("summary")}}  element that provides summary for a {{HTMLElement("details")}}  element. Developers shouldn’t add the tabindex attribute to these elements unless it changes the default behavior (for example, including a negative value will remove the element from the focus navigation order).

[!WARNING] The tabindex attribute must not be used on the {{HTMLElement("dialog")}}  element.

Accessibility concerns

Avoid using the tabindex attribute in conjunction with non-interactive content to make something intended to be interactive focusable by keyboard input. An example of this would be using a {{HTMLElement("div")}}  element to describe a button, instead of the {{HTMLElement("button")}}  element.

Interactive components authored using non-interactive elements are not listed in the accessibility tree. This prevents assistive technology from being able to navigate to and manipulate those components. The content should be semantically described using interactive elements ({{HTMLElement("a")}} , {{HTMLElement("button")}} , {{HTMLElement("details")}} , {{HTMLElement("input")}} , {{HTMLElement("select")}} , {{HTMLElement("textarea")}} , etc.) instead. These elements have built-in roles and states that communicate status to the accessibility that would otherwise have to be managed by ARIA.

Specifications

{{Specifications}} 

Browser compatibility

{{Compat}} 

See also

In this article

View on MDN