Sub topic 6
Writing link text that makes sense out of context
This chapter assumes you can write an a element with an href, and that you know the difference between an element's content and its attributes. You don't need any CSS beyond reading a short class rule.
Why link text is read out of context
Sighted visitors often scan a page for links. Screen reader users have an equivalent tool: the links list. Most screen readers can pull every link out of the page and read them as a flat list, with none of the surrounding sentences. Voice-control users also say the visible link text to activate a link. Search engines use link text to learn what the target page is about.
In all of these cases, the link text has to stand on its own. Compare two lists of links as a screen reader would present them:
- click here, click here, read more, read more, this page
- Download the 2024 annual report, Pricing plans, Contact support, Accessibility statement
The first list is useless. The second tells you where each link goes.
The basic rule
The visible text inside the a element should describe the destination or the action. A good test: delete all the text around the link and read only the link. If you still know what will happen, the text works.
<!-- Weak: the meaning depends on the sentence around it -->
<p>To read about our refund policy, <a href="/refunds.html">click here</a>.</p>
<!-- Better: the link describes its destination -->
<p>Read our <a href="/refunds.html">refund policy</a>.</p>Link the words that name the destination, not the whole sentence and not a bare verb. Linking an entire paragraph makes the links list long and noisy. Linking only "here" tells the reader nothing.
Common errors
| Pattern | Problem | Fix |
|---|---|---|
| "Click here", "here" | No meaning out of context. "Click" also assumes a mouse. | Name the destination. |
| "Read more" repeated on every card | Many identical links with different targets. | Add the article title to the link text. |
| A raw URL as link text | Long strings are tedious to hear and often meaningless. | Use a descriptive phrase. |
| Link text that differs from its image's alt | Confusing when an image link has no text of its own. | Make the alt describe the destination. |
| Same text, different destinations | Users can't tell the links apart. | Make each text unique. |
Two links with the same text should go to the same place. If they don't, rewrite one of them.
Repeated "Read more" links
News listings and card layouts are where this goes wrong most often. There are three common fixes, in order of preference.
The first is to put the real title in the link text and drop the generic one:
<article>
<h2><a href="/news/new-library-hours.html">New library hours start in January</a></h2>
<p>The main branch will open an hour earlier on weekdays.</p>
</article>The second is to keep a "Read more" link but include the context in the text. A visually hidden span keeps the visible design the same:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>News</title>
<style>
.visually-hidden {
position: absolute;
width: 1px;
height: 1px;
margin: -1px;
padding: 0;
overflow: hidden;
clip-path: inset(50%);
white-space: nowrap;
border: 0;
}
</style>
</head>
<body>
<article>
<h2>New library hours start in January</h2>
<p>The main branch will open an hour earlier on weekdays.</p>
<a href="/news/new-library-hours.html">Read more<span class="visually-hidden"> about new library hours</span></a>
</article>
</body>
</html>Note the leading space inside the span. Without it, the screen reader would announce "Read moreabout".
The third is aria-label, which replaces the accessible name of the link:
<a href="/news/new-library-hours.html" aria-label="Read more about new library hours">Read more</a>This works, but it has a trap. The label replaces the visible text for assistive technology, so it should start with the visible words. If the visible text says "Read more" and the label says "Library hours article", voice-control users who say "click Read more" may fail to activate the link. Prefer the visually hidden span when you can, since it also gets translated by browser translation tools.
Telling users what to expect
A link that does something unusual should say so in its text. This includes file downloads, new tabs, and other formats.
<a href="/files/annual-report-2024.pdf" download>Annual report 2024 (PDF, 2.4 MB)</a>
<a href="https://example.com/" target="_blank" rel="noopener noreferrer">Example site (opens in a new tab)</a>The file type and size help users on slow connections decide whether to download. Warning about a new tab matters because a new tab breaks the Back button, which can disorient people who don't see the tab change.
Keep link text short but complete
Aim for roughly two to six words. Longer text is hard to scan, and a whole sentence turns the links list into a wall. Avoid starting every link with the same filler such as "Link to" or "Go to". Screen readers already announce the word "link", so "Link to pricing" is heard as "link, link to pricing".
Don't make links differ only in punctuation or case. Also avoid splitting one link across several adjacent anchors with the same href, because each becomes a separate stop for keyboard users. Use one anchor around the whole phrase.
Links without text
An a element with no text and no accessible name is read as just "link", or as the raw URL. This often happens with icon-only links:
<!-- Broken: nothing to announce -->
<a href="https://example.com/feed.xml"><svg width="16" height="16" aria-hidden="true"></svg></a>
<!-- Fixed: the hidden text names the destination -->
<a href="https://example.com/feed.xml"><svg width="16" height="16" aria-hidden="true"></svg><span class="visually-hidden">Subscribe to the news feed</span></a>The aria-hidden="true" on the icon stops the screen reader from announcing it. For image links, the alt text takes the role of link text, and a later chapter covers that case.
A decision flow
Checking your work
- Open the page and use your screen reader's links list, or tab through the links and read each one aloud.
- Search the source for
>here<,>click here<, and>read more<. - Look for two anchors with identical text and different
hrefvalues. - Check that every icon-only link has an accessible name.
Exercise
A product page has three cards, each with a link reading "Learn more" that goes to a different product page. Rewrite the first card's link (to /products/trail-shoes.html) without changing how "Learn more" looks on screen. Which technique did you use, and why is it better than a plain aria-label that says "Trail shoes details"?
Show answer
<a href="/products/trail-shoes.html">Learn more<span class="visually-hidden"> about trail shoes</span></a>. The visually hidden span keeps "Learn more" visible and adds the product name to the accessible name. A label that doesn't begin with the visible words ("Trail shoes details") can make voice-control commands like "click Learn more" fail, because the spoken name no longer matches what the user sees.