The tabindex HTML attribute controls programmatic and sequential focus behavior:
tabindex="0": Inserts an element into the natural keyboard tab order in its current DOM position. (Used when creating accessible custom interactive widgets).tabindex="-1": Removes an element from the sequential keyboard tab order, but makes it programmatically focusable via JavaScript (element.focus()). (Used for modal containers, error alert banners, and custom roving focus widgets).tabindex="1" or greater (POSITIVE TABINDEX):
Strict Anti-Pattern: Positive tabindex values hijack the browser's tab flow, forcing focus to jump arbitrarily before all natural elements. Never use positive tabindex!
Level 1 · Accessible interaction basics