Accessibility
a11y/positive-tabindex
No element has a tabindex greater than 0; focus order follows the source order.
seriousstaticWCAG 2.4.3 · Afe-a11y-keyboard
Why
A positive tabindex moves the element ahead of everything else in the Tab order, so keyboard users jump around the page in an order that no longer matches what they see.
Fix
Use tabindex="0" to make a custom control focusable in source order and tabindex="-1" for something focused only by script. Change the order by changing the DOM order, not tabindex.
Examples
<!-- bad -->
<button tabindex="3">Save</button>
<!-- good -->
<button>Save</button>Sources
Facts
- Id
a11y/positive-tabindex- Severity
- serious
- Check
- static checked in the source by
audit - Applies to
htmlangularvuesvelteastrojsx- WCAG 2.2
- 2.4.3, level A
- Same problem in
- axe-core
tabindex - Taught by the skill
fe-a11y-keyboardKeyboard access and focus- Since version
- 0.1.0
Read it in the terminal
npx github:dawidolko/frontend-skills explain a11y/positive-tabindex