Why is this an issue?

When two links share the same parent element, have identical visible text, 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—same-text links 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 identical link text when the surrounding context (for example, the enclosing list item or table row) provides disambiguation.

Exceptions

This rule only considers <a> elements.

When present, aria-labelledby or aria-label determines the name compared instead of the visible text, since that is what a screen reader announces for the link. aria-labelledby takes precedence over aria-label, which in turn takes precedence over the visible text. aria-labelledby is compared by its id reference rather than by resolving the text of the referenced element, so two links referencing different ids are never flagged against each other even if the referenced elements happen to contain the same text; for the same reason, a link identified by aria-labelledby or aria-label is never compared against a link identified by its plain visible text.

A link with no text content is not considered by this rule; a completely empty link is reported by {rule:Web:S6827} instead.

A link that is hidden from assistive technologies, for example with aria-hidden="true", or hidden from every user, for example with the hidden attribute, is not considered by this rule either, since it would never be announced by the screen reader that lists all links on the page. This also applies when the link inherits that state from an ancestor: hiding a container hides everything inside it.

A link inside a conditional block, for example an @if/@else pair or an anchor carrying v-if/v-else, is not compared against a link in a different branch of the same condition.

Code examples

Noncompliant code example

<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>

Compliant solution

<div>
  <a href="/user/1/edit">Edit Alice</a>
  <a href="/user/2/edit">Edit Bob</a>
</div>

Resources

Documentation

Related rules