squirrelscan
GitHub

Anchor text: descriptive links for search and screen readers

Anchor text is the visible, clickable text of a link. Why descriptive text helps search engines and screen reader users, and what generic text costs.

Anchor text is the visible, clickable text of a link, which tells readers and search engines what they will find at the other end.

Google’s link guidance says good anchor text is descriptive, reasonably concise and relevant to both the page it is on and the page it points to. For an image link, the image’s alt text plays that part. WCAG 2.2 success criterion 2.4.4, Link Purpose (In Context), asks that the purpose of each link can be told from its text alone, or from the text together with its surrounding context.

Category: Links

Why it matters

Screen reader users often pull up a list of a page’s links and move through it out of context. A list of “Read more”, “Click here” and “Learn more” tells them nothing, and an icon link with no name is announced as a bare link. For search engines the text is a description of the target, so “click here” wastes it. The same text pointing at two different pages is a related problem: “Learn more” under every card on a pricing page sends readers to different places with the same promise.

How squirrelscan checks it

links/anchor-text groups the links on each page by destination. It warns when no link to a destination has any accessible name, and notes at info level when every named link to it uses generic text such as click here, read more or learn more. Pages in several other languages are checked against that language’s generic phrases as well. a11y/link-text fails links with no accessible text at all, including an icon font or an unnamed SVG, and warns on 48 generic phrases. Conventional labels such as “Sign in” or “Privacy policy” are never reported as generic. a11y/identical-links-same-purpose warns when one link text leads to more than one destination. It compares URLs as written, so /pricing and https://example.com/pricing count as different.

RuleWhat it flagsSeverity
Empty and generic anchor text: click here and iconsA link with no text has no name, and click here describes nothing. squirrel groups links by destination and checks each group for a descriptive name.warning
Link text: why ‘click here’ fails and what to useLinks reading ‘click here’, and links wrapping an unlabeled icon, give screen reader users nothing to go on. squirrel lists both kinds.warning
Identical link text pointing at different pagesTwo links reading ‘Learn more’ that go to different places are indistinguishable in a screen reader’s link list. squirrel finds them.warning

How to fix it

Write the destination into the link, and name icon links with aria-label:

<a href="/pricing">View our pricing plans</a>

<a href="/search" aria-label="Search">
  <svg aria-hidden="true">...</svg>
</a>

When the design needs a short visible label, keep it and put the full phrase in aria-label, with the visible words inside it (the link text fix). For a card, wrap the image and headline in one link and give the image alt="", so the headline is the name. Two separate links each need a name of their own (the anchor text fix). Make repeated labels specific, such as “Learn more about the Team plan” (the same-purpose fix).

Run the check

squirrel audit https://example.com --rule-include links/anchor-text,a11y/link-text,a11y/identical-links-same-purpose

A signed-out local audit costs nothing.

  • Internal linking: Links between pages of the same site, which carry crawlers and readers through it and signal which pages matter.
  • Accessible name: The name assistive technology announces for an element, computed from its content, label, aria-label or aria-labelledby.

References

Type to search…

↑↓ navigate↵ openesc close