Accessibility Design Guidelines:

Hyperlinks and Buttons

page structure image
Source: Photo Jess Bailey on Pexels

Why is this Important?

Hyperlinks, buttons and other clickable elements are a gateway to completing online tasks. If they are not designed with accessibility in mind, they may not be perceivable or identified by users with disabilities.

For example, a person with motor impairments may have difficulty accessing small icon buttons using a mouse. Or, individuals with cogitive limitations who cannot determine the purpose of an uninformative text link or button text description. Lastly, users with vision impairments such as colour-blindness cannot identify a text link by colour alone and therefore, it must be identified by using the css declaration text-decoration: underline;

Whether it is a text link, button or an icon (image) link, certain considerations must be made to ensure that these elements can be easily accessed. Ensuring appropriate contrast, font-size, touch-point size, as well as using semantic HTML code, must be implmented according to meet AODA specifications, in all situations.

This is a button: ADD TO CART

This is a text link: Read more about AODA.

broken image link Source: Melinda Neale

"The intent of Success Criterion 2.4.4 Link Purpose (In Context) is to provide link text that identifies the purpose of the link without needing additional context. Link text that is meaningful will aid users in choosing from a list of links."

Best Practices

  • For screen readers, always use semantic HTML for buttons and link elements.
  • For hyperlinks, include the <role="link"> attribute so that screen readers can translate its meaning to the user. Figure B:
  • If other elements are used as buttons, use the <role="button"> attribute.
  • Incorporate good contrast between link text and background elements.
  • Identify link text by using the css declaration text-decoration: underline;
  • Image icons used for input elements should include alternative text. Figure A:
  • Links and buttons should include text that describes its purpose. Figure B:

Below are examples of how to design hyperlinks and buttons in accordance with AODA guidelines. These will vary depending upon the purpose of the link or button displayed and its context on a webpage.

                        <input type="image" alt="search" src="searchButton.png">
                    

Figure A: Images used for input buttons, such as a search bar, should include alternative text.

                        <a href="https://www.aoda.ca/" role="link"> Read more about AODA</a>
                    

Figure B: Links and buttons should include text that describes its purpose.

EXAMPLES

Click on the icons below to reveal the corresponding WCAG Success Criteria

Example 1

Button vs DIV Element

It is always best practice to use semantic HTML when developing webpages, particularly when creating <button> and <a> links. However, if a <div> tag is used, be sure to identify it's role to the screen reader by adding the <role="button"> attribute. See Figure A and B.

"The value of aria-pressed="" describes the state of the button. The values include aria-pressed="false" when a button is not currently pressed, aria-pressed="true" to indicate a button is currently pressed, and aria-pressed="mixed" if the button is considered to be partially pressed. If the attribute is omitted or set to its default value of aria-pressed="undefined", the element does not support being pressed." [Reference: MDN]

                    <div role="button" aria-pressed="false" type="submit" tabindex="0">Add to Cart</div>
                

Figure A: Assigning the role="button" attribute allows the screen reader to appear as a button.

                    <buttonaria-pressed="false" type="submit">Add to Cart</button>
                

Figure B: The semantic button tag automatically identifies itself as a button to screen readers.

Example 2

Meaningful Text Links

Text links are hyperlinks that fall within the context of a sentence or description. Text links do not contain images. Developers should use the <a> tag when creating hyperlinks. By default, the <a> tag has accessibility features built in to it.

The text used within the clickable area must contain certain characteristics that make it accessible to users:

  • Use meaningful hyperlink text that clearly explains the destination of the resource being hyperlinked. See Figure B
  • Hyperlink text should not include the entire URL as it is not reliably comprehensive information.
  • The text notifies the user if the link is to download a file.
  • The text notifies the user if the link opens in a new window/tab. See Figure C and D
                    <a href="#" role="link" target="_blank">Buy Now</a>
                    <i class="fa fa-external-link" aria-hidden="true"></i>
                    <span class="sr-only"> external link icon</span>
                

Fig D: The <span> element is visually hidden, but read by screen readers.

"The intent of Success Criterion 2.4.4 Link Purpose (In Context) help users understand the purpose of each link so they can decide whether they want to follow the link. Whenever possible, provide link text that identifies the purpose of the link without needing additional context."

For more information about The Friendly Flower Shop click here.

Figure A: 'Click here' does not provide meaning to the user.

For more information, see The Friendly Flower Shop.

Figure B: Use meaningful hyperlink text that explains the destination.

For more information, see The Friendly Flower Shop external link icon

Or, when used in a button: external link icon  Buy Now

Figure C: Use a visual indicator that a link will open in a new tab.

Example 3

The "Focus" State

The focus state is a 'selector' used in css to help people who use a keyboard navigate a web page. When users tab through navigational menus items, links and form fields, the selected element has a highlighted border; visually identifying which HTML element is selected.

While they do require mark-up to apply and it may not be the desired visual effect the designer is striving for, adding a focus state indicates the 'selected' location to aid people using keyboards while navigating a webpage. See working example below:

[role="button"], button:focus{
                      outline: 2px solid blue;
                    }
                

NOTE: Browsers have different ways of displaying the focus of a link. Use CSS to apply the desired look, but remember that legibility is key to achieving web-accessibility.

Example 4

Icons Images as Buttons

Images icons are intended to generate a meaning or purpose to a user, such a as a 'share' icon. These buttons are often presented as symbols. In these cases, the icon image should have a text description assigned to it to translate it's meaning. This benefits individuals with elderly persons and people with cognitive and visual impairments.

                    <button class="button">
                      <img src="cart.svg" alt="cart button">CART
                </button>
                

NOTE: If you do not use text, be sure to add this code below so that the icon names can still be identified by screen readers:

                    <span class="visually-hidden"> CART</span>
.visually-hidden{   border:0;clip:rect(0,0,0,0);height:1px;overflow: hidden;padding:0;position:absolute;width:1px; }
icons as buttons

TOP: The top set of icon images have no related text description to support the symbols meaning.

BOTTOM: The bottom set of icon images relay the meaning of the button to a user. In this case, the text should not be embedded into the image but rather, as part of the website code. See example.

In addition to including text as a accessible name for a button, also ensure it has a meaningful text alternative.

Example 5

Using a Logo Image as a Link

Logo images usually appear at the top of every webpage in the same location throughout a website. These link to the website's homepage. If the logo image used does not contain the name of the company or convey information to that affect, a descriptive text link should be provided in conjunction with alternative text.

flower logo
example pop up icon Friendly Flower Shop example pop up icon
                    <a href="" role="link">
                      <img src="flowerlogo.svg" alt="flower shop logo">
                      Friendly Flower Shop
                    </a>
                

NOTE: It is recommended to add a visible text link to convey the purpose of a logo when it is used as a link. (Ref: W3C]external link

The Success Criteria for Hyperlinks and Buttons

Who Does This Benefit?

user IconUsing Keyboards for Navigation

vision IconVisual Impairments

computer IconPerson with a Motor Impairment

brain IconCognitive and Learning Disabilities

The Related WCAG Success Criteria

1.1.1 Non-text Content

All non-text content that is presented to the user has a text alternative that serves the equivalent purpose, except for the situations listed below.
(Level A)

1.4.5 Images of Text

If the technologies being used can achieve the visual presentation, text is used to convey information rather than images of text. Note: Logotypes (text that is part of a logo or brand name) are considered essential.
(Level AAA)

2.4.4 Link purpose (in context)

The purpose of each link can be determined from the link text alone or from the link text together with its programmatically determined link context, except where the purpose of the link would be ambiguous to users in general.
(Level A)

3.2.1 On Focus

When any component receives focus, it does not initiate a change of context.
(Level AA)