When two links share the same parent element, have identical accessible names, but point to different destinations, screen readers and assistive technologies that list all links on a page will present the user with two indistinguishable entries leading to different places.
This specific situation, links with the same accessible name that are siblings in the same container, is the one case where context cannot
disambiguate the purpose of each link. Links in separate containers (different <article>, <li>,
<div>, or other elements) are intentionally not flagged: WCAG 2.4.4 explicitly allows an identical accessible name when the
surrounding context (for example, the enclosing list item or table row) provides disambiguation.
The accessible name compared here follows the same computation screen readers use, and may come from aria-label,
aria-labelledby, or title attributes rather than the link’s visible text alone.
This rule only considers native <a> elements written in JSX.
A link with no accessible name at all is not considered by this rule; see {rule:javascript:S6827}.
A link that is hidden from assistive technologies, for example with aria-hidden, or hidden from every user, for example with the
hidden attribute or display: none, is not considered by this rule either, since it would never be announced by the screen
reader that lists all links on the page.
Two links found in mutually exclusive branches of the same condition, such as the two branches of a ternary expression or an
if/else pair, are never compared with each other, since a user can never be presented with both links at the same time.
<div>
<a href="/user/1/edit">Edit</a>
<a href="/user/2/edit">Edit</a> {/* Noncompliant: use a distinct text or label, or point to the same target for this link and the one above */}
</div>
<div> <a href="/user/1/edit">Edit Alice</a> <a href="/user/2/edit">Edit Bob</a> </div>
Changing the visible text is not always desirable, for example when a design system requires every card in a list to use the same "Read more"
label. In that case, keep the text and give each link a distinct accessible name with aria-label instead.
<div>
<a href="/posts/1">Read more</a>
<a href="/posts/2">Read more</a> {/* Noncompliant: use a distinct text or label, or point to the same target for this link and the one above */}
</div>
<div> <a href="/posts/1" aria-label="Read more about the first post">Read more</a> <a href="/posts/2" aria-label="Read more about the second post">Read more</a> </div>