org.sonar.l10n.javascript.rules.javascript.S6827.html Maven / Gradle / Ivy
Why is this an issue?
Anchors, represented by the a
tag in HTML, usually contain a hyperlink that users can click to navigate to different sections of a
website or different websites altogether.
However, when anchors do not have content or when the content is hidden from screen readers using the aria-hidden
property, it creates
a significant accessibility issue. If an anchor’s content is hidden or non-existent, visually impaired users may not be able to understand the purpose
of the anchor or navigate the website effectively.
This rule checks that anchors do not use the aria-hidden
property and have content provided either between the tags or as
aria-label
or title
property.
How to fix it
Ensure that anchors either have content or an aria-label
or title
attribute, and they should not use the
aria-hidden
property.
Code examples
Noncompliant code example
<a aria-hidden>link to my site</a>
Compliant solution
<a>link to my site</a>
Resources
Documentation
- MDN web docs -
<a>
: The Anchor element
- MDN web docs -
aria-hidden
attribute
Standards
- W3C - Link purpose