Navigation using the Tab key should be restricted to elements on the page that users can interact with.
The misuse of the tabindex attribute can lead to several issues:
If the element is not meant to be interactive, remove the tabindex attribute or set it to -1 so it is skipped by
sequential keyboard navigation.
If the element is meant to be interactive, prefer a native interactive element such as <button> or <a href>.
When a custom widget is required, give it the appropriate interactive role, keep it keyboard reachable, and implement the keyboard
behavior that role expects.
<div tabindex="0">Save</div>
<button type="button">Save</button>
<div role="button" tabindex="0" onclick="save()"
onkeydown="if (event.key === 'Enter' || event.key === ' ') save();">
Save
</div>
This rule accepts tabindex="0" on elements with role="tabpanel". This matches the WAI-ARIA Tabs pattern, which allows the
tabpanel itself to receive focus when its first meaningful content is not focusable.
<div role="tabpanel" tabindex="0"> <!-- tab content --> </div>