Skip to content

Latest commit

 

History

History
37 lines (24 loc) · 805 Bytes

tabindex-uses-button.md

File metadata and controls

37 lines (24 loc) · 805 Bytes

tabindex-uses-button

When an anchor has a tabIndex, but no href and no role properties, it is likely you are using it to emulate a button. Prefer using role="button" or just use the <button> element.

options

This rule takes no options

Passes

// passes when anchor has no `tabIndex`
<a></a>

// passes when anchor has `role="button"`
<a role="button" tabindex="1"></a>

// passes when anchor has a `href`
<a href="foo" tabindex="1"></a>

// passes when the anchor is hidden
<a tabindex="1" aria-hidden="true"></a>

Fails

// fails when anchor has tabIndex but no button
<a tabindex="1"></a>

See also