Links

Screen readers enable users to skim links on a page, moving from one to the next without declaring the neighboring text. Whenever possible, provide link text that identifies the purpose of the link without needing additional context. According to the Canada.ca Content Style Guide, “Your links should be descriptive and able to stand alone so that it's clear what people can expect if they click on them.

People with visual disabilities can also determine the purpose of a link by exploring the link's context. If writing stand-alone link text is impossible, ensure the link text identifies its purpose in combination with one of the following:

  • The enclosing sentence
  • The enclosing list item
  • The enclosing paragraph
  • The enclosing table cell and table header cell
  • The parent list item of a nested list (example follows)

Do not use information-empty link text such as “click here” or “Read More” etc.

If two or more links on the same page have identical link text but different destinations, you can distinguish the links from one another in one of three ways:

  • Rephrase the link text.
  • Use an ARIA label (either the aria-label or aria-labelledby attribute). The ARIA label supercedes the native link text in assistive technology. Be sure to include the visible link text in the ARIA label, so voice input users can target the link (see Link Activation, below).
  • Add visually-hidden text to the link text (example follows).

Developers frequently confuse the link and button roles, passing the confusion on to screen reader users. Users expect links to navigate (across pages or within a page), and buttons to trigger a local effect (or submit a form). A screen reader user can be disorientated when activating a button and instead navigating to a new page, or when activating a link and instead interpreting a local button effect.

In this example, the link text “how much” communicates nothing useful:

A Food Guide Serving is simply a reference amount. It helps you understand how much food is recommended every day from each of the four food groups. In some cases, a Food Guide Serving may be close to what you eat, such as an apple. In other cases, such as rice or pasta, you may serve yourself more than one Food Guide Serving.

In this example, the purpose of the link is perfectly clear.

A Food Guide serving is how much food you should eat from each of the 4 food groups every day. In some cases, a serving is the amount of a given food group that you normally eat in one sitting, like an apple. In other cases, the daily amount is more than one serving, such as for rice or pasta.

Number of daily food servings for children, teens and adults

In this example, the visible link text “Access” is repeated for each resource. When there's no avoiding duplicated, visible link text, you can distinguish each instance with the aria-label attribute.

HTML

<h1>Tools and resources</h1>

<h2>Planning Accessible Virtual Events – Job Aid</h2>
<p>[Description of the resource]</p>
<p>
   <a href="[...]" aria-label="Access Planning Accessible Virtual Events – Job Aid">Access</a>
</p>

<h2>Employees with Disabilities Network (EwDN)</h2>
<p>[Description of the resource]</p>
<p>
   <a href="[...]" aria-label="Access Employees with Disabilities Network">Access</a>
</p>

Again, the visible link text “Access” is repeated for each resource. You can distinguish each instance with the aria-labelledby attribute, pointing to one or more id attribute values of elements containing the desired label. In this example, the label concatenates the link text + the preceding heading.

Note that one instance of the link text “Access” with an id attribute can be referenced by multiple ARIA labels, which may be more convenient than creating an id attribute for each instance of the link “Access”.

HTML

<h1>Tools and resources</h1>

<h2 id="planning-virtual">Planning Accessible Virtual Events – Job Aid</h2>
<p>[Description of the resource]</p>
<p>
   <a id="linktext" href="[...]" aria-labelledby="linktext planning-virtual">Access</a>
</p>

<h2 id="ewdn">Employees with Disabilities Network (EwDN)</h2>
<p>[Description of the resource]</p>
<p>
   <a href="[...]" aria-labelledby="linktext ewdn">Access</a>
</p>

In this example, the duplicated link text “Access” is extended with text that’s been visually-hidden using the CSS "clip" method. The text is invisible, but it’s still in the HTML and so is encountered by assistive technology.

HTML

<h1>Tools and resources</h1>

<h2>Planning Accessible Virtual Events – Job Aid</h2>
<p>[Description of the resource]</p>
<p>
   <a href="[...]">
      Access
      <span class="wb-inv">Planning Accessible Virtual Events – Job Aid</span>
   </a>
</p>

<h2>Employees with Disabilities Network (EwDN)</h2>
<p>[Description of the resource]</p>
<p>
   <a href="[...]">
      Access
      <span class="wb-inv">Employees with Disabilities Network</span>
   </a>
</p>

CSS

.wb-inv {
   clip: rect(1px,1px,1px,1px);
   height: 1px;
   margin: 0;
   overflow: hidden;
   position: absolute;
   width: 1px;
}
Related WCAG resources

Success criteria

Techniques

Failures

Some people with disabilities are not able to use a mouse and instead leverage mechanisms such as keyboard, voice control and alternative pointing devices to navigate and interact with web. Ensure that links (and buttons and other controls) are focusable and actionable by keyboard and voice input and not just via a mouse.

Native links are keyboard-activated by pressing the Enter key. If you design a custom link using the ARIA role="link" attribute and a div or span element, include:

  • A tabindex="0" attribute, so that the custom link receives keyboard focus via the Tab key.
  • A JavaScript event listener for the Enter key for activation, in addition to mouse click.

To activate a link using voice input, the user declares the name of the link as visible. When using aria-label or aria-labelledby to name a link, ensure the link's visible text matches or is included in the ARIA label. Otherwise, voice input users won't be able to target the link by name, forcing them to switch to less efficient techniques to activate the link.

Related WCAG resources

Success criteria

Techniques

Failures

Visual focus indicator

For keyboard only users, visually tracking where they are in a page can be challenging. Mouse users can roam the page and receive two clues about actionable items: the mouse arrow turns into a hand when hovering over an actionable item, and the element displays its "hover" state to indicate it’s actionable (e.g., an underline appears under a link).

Typically, keyboard users press the Tab key to navigate the interactive elements on a web page (links, buttons, form fields, custom controls).

  • Tabbing to an item gives it keyboard "focus", at which point it can be activated with the keyboard. See the section Focus and focus order later in this module.
  • Sighted keyboard users need visible feedback of a control's focus state.

Web browsers provide a default visual focus indicator that varies in appearance by browser but usually consists of a border or outline around the focused element.

  • Always avoid styles that remove or limit the visibility of keyboard focus indicators. The browser default visual focus indicator can be removed with CSS outline:0 or outline: none, which is a common barrier and anti-pattern.
  • It's best practice to use CSS to design a highly-visible focus indicator with strong contrast.

 Bad example: Visual focus indicator is removed

All browsers display a visible outline around the element that currently has keyboard focus, which can be disabled using the outline: 0 or outline: none CSS property. If the visual focus indicator is removed, sighted keyboard users will have no idea which link has the focus, making it difficult or impossible to navigate the web page.

A link to Google

CSS

a:focus {
   outline: none;
}

 Good example: Canada.ca visual focus indicator

In this example, the first link in a menu of three has a visual focus indicator consisting of a thick black outline, set closely to the text.

CSS

a:focus { 
   outline: 2px auto -webkit-focus-ring-color; 
   outline-offset: -2px; 
}
Screenshot showing the visual focus indicator on a link, consisting of a thick black outline, set closely to the text.

Related WCAG resources

Related WCAG resources

Success criteria

Techniques

Failures

Users with low vision and colour blindness need to distinguish links from neighboring text. The easiest way to do this is with an underline on the link.

When colour is used as the only way to identify a link (meaning the underline has been removed), two conditions must be met:

  • 3:1 contrast between the body text and the link text.
  • A "visual cue" (not just a color change) that appears on mouse hover and keyboard focus. The most common way to meet this is to underline the link on hover and focus, but you could also provide a background colour or border or outline.

Note that this is only an issue when the link and the body text appear together. It doesn’t apply to links in the header or stacked in a menu, where they’re understood to be links by their position on the page.

These requirements are in addition to the minimum text contrast requirement of 4.5:1 (see tutorial module 7 Visual design and colours > Contrast). It can be difficult to find a link colour that has both a 3:1 contrast with black body text and a 4.5:1 contrast with a white background. WCAG Technique G183 lists colour values that do, in Example 1 (see Related WCAG resources, below).

Related WCAG resources

Success criteria

Techniques

Links open in a new window via the target="_blank" attribute.

In general, avoid opening links in a new window. When links do open in a new window, warn users. Either:

  • Add the visible link text “(Opens in new window)”.
  • Reveal a visually-hidden warning on focus and hover (see example).

HTML

<p>
   This is an example of an 
   <a class="info" href="[...]" target="_blank">
      <strong>External link</strong>
      <span>Opens a new window</span>
   </a>          
</p>

Until the link receives focus, the inner span is visually hidden using the CSS "clip" method. On hover or focus, the warning “Opens in new window” (or “Opens in new tab”) is made visible. See WCAG Technique G201 for the complete HTML and CSS.

Consider styling the warning to appear like the title attribute tooltip.

Related WCAG resources

Success criteria

Techniques

Back to top