Avoid Positive Tabindex
ID |
html.positive_tabindex |
Severity |
low |
Remediation Complexity |
low |
Remediation Risk |
low |
Remediation Effort |
low |
Resource |
Reliability |
Language |
Html |
Tags |
accessibility, reliability |
Rationale
A positive tabindex pulls the element ahead of the natural DOM order in the keyboard focus
sequence. This almost always desynchronises the visual layout from the tab order, surprises keyboard
users, and is brittle to maintain as the page evolves. tabindex="0" (natural order) and
tabindex="-1" (focusable only via script) are both fine.
<button tabindex="1">Save</button> <!-- FLAW — positive tabindex -->
<button tabindex="0">Save</button> <!-- OK — natural focus order -->
Remediation
Remove the positive value and rely on the DOM order, or use tabindex="0" to make a non-interactive
element focusable in its natural position.