tabindex

The tabindex global attribute controls whether and in what order an element is keyboard focusable.

Since HTML 4.0 Spec ↗

Syntax

tabindex="0"

Examples

<div tabindex="0" role="button">Custom button</div>
<div tabindex="-1" id="focus-target">Programmatic focus only</div>
Output
The first div joins the natural tab order; the second is focusable only via script (element.focus()).

Notes

Use tabindex="0" to make custom widgets focusable and tabindex="-1" for programmatic focus. Avoid positive values; they create confusing, hard-to-maintain tab orders.

Browser & runtime support

EnvironmentSince version
chrome 1.0
firefox 1.0
safari 1.0
edge 12

See also