Anchors must have content and the content must be accessible by a screen reader
That makes sense for this:
<a href="#example">
<div class="box"></div>
</a>
But if you are doing a purely presentational image with clickable zones and want screen readers to skip the section entirely, you can add role="presentation" and aria-hidden:
This is pointless though, as the text exists for screen readers, but the screen reader will not ever see it.
Also the tabindex="-1" is important, as it takes the link out of keyboard navigation. Without this you could tab to the link, but the screenreader wouldn't be able to explain what just happened because you are in an aria-hidden element that it wants to skip.
anchor-has-content
That makes sense for this:
But if you are doing a purely presentational image with clickable zones and want screen readers to skip the section entirely, you can add
role="presentation"
andaria-hidden
:In this context, there is no need to add additional text inside the link, so the linter should pass.
Current workaround:
This is pointless though, as the text exists for screen readers, but the screen reader will not ever see it.
Also the
tabindex="-1"
is important, as it takes the link out of keyboard navigation. Without this you could tab to the link, but the screenreader wouldn't be able to explain what just happened because you are in anaria-hidden
element that it wants to skip.