About This HTML Issue
An element with role="tab" is interactive, so it can't sit inside an <a> element, which is interactive too.
The content model of <a> forbids interactive descendants, and ARIA in HTML counts any element with an interactive role, such as tab, as one. When a tab sits inside a link, assistive technologies get two controls in one spot: the outer element is announced as a link, the inner one as a tab, and it's unclear which of the two a click or the Enter key activates. The link also gets between the tablist and its tabs, so screen readers may not announce the tab's position in the set.
This markup often comes from older accordion components, where a link wraps the clickable header and the header carries role="tab". Keep one interactive element per control. For a set of tabs, put role="tab" on the control itself, usually a <button>, inside a role="tablist" container. An <a href> may also take role="tab" directly, but then it behaves as a tab, not a link. If the component is really an accordion, drop the tab roles and use a button inside a heading.
Invalid example
<div role="tablist">
<a href="#panel-1">
<div role="tab" id="tab-1">Shipping</div>
</a>
<a href="#panel-2">
<div role="tab" id="tab-2">Returns</div>
</a>
</div>
<div id="panel-1" role="tabpanel" aria-labelledby="tab-1">Orders ship within two days.</div>
<div id="panel-2" role="tabpanel" aria-labelledby="tab-2" hidden>Returns are free for 30 days.</div>
Valid example
<div role="tablist">
<button type="button" role="tab" id="tab-1" aria-selected="true" aria-controls="panel-1">Shipping</button>
<button type="button" role="tab" id="tab-2" aria-selected="false" aria-controls="panel-2" tabindex="-1">Returns</button>
</div>
<div id="panel-1" role="tabpanel" aria-labelledby="tab-1">Orders ship within two days.</div>
<div id="panel-2" role="tabpanel" aria-labelledby="tab-2" hidden>Returns are free for 30 days.</div>
Valid example for an accordion
<h3>
<button type="button" aria-expanded="false" aria-controls="section-1">Shipping</button>
</h3>
<div id="section-1" hidden>Orders ship within two days.</div>
Tab switching and the aria-expanded toggle still need JavaScript, but the markup no longer nests one control inside another.
Find issues like this automatically
Rocket Validator scans thousands of pages in seconds, detecting HTML issues across your entire site.