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.
This rule takes no options
// 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 when anchor has tabIndex but no button
<a tabindex="1"></a>
- This document from developer.mozilla.org