Skip to main content

tabindex_no_positive

Prevents using positive tabindex values, which are very easy to misuse with problematic consequences for keyboard users.

User impact: Serious

This rule supports the following configuration:

# Avoid positive `tabindex` values, change the order of elements on the page instead.
tabindex_no_positive = true

Success#

<!-- Good: No tabindex attribute โ€“ rely on the order of elements -->
<!-- tabindex_no_positive = true -->
<input type="text" name="username" />
<!-- Good: Not recommended but valid -->
<!-- tabindex_no_positive = true -->
<div role="button" tabindex="0">ARIA button</div>
<!-- Good: Use -1 where appropriate, so elements can programmatically receive focus -->
<!-- tabindex_no_positive = true -->
<div tabindex="-1">I can receive focus via JS</div>

Fail#

<!-- Bad: Positive values are problematic -->
<!-- tabindex_no_positive = true -->
<button type="submit" tabindex="3">Sign in</button>

Resources#