Back to 2.4.4 Link Purpose (In Context)
- 1 Background
- 2 Assumptions
- 3 Test properties
- 4 Test procedure
- programmatically determined link context
- H30: Providing link text that describes the purpose of a link for anchor elements
- Accessible Name Calculation algorithm
- HTML to Platform Accessibility APIs Implementation Guide (section 6.10)
- ARIA7: Using aria-labelledby for link purpose
- ARIA8: Using aria-label for link purpose
- H77: Identifying the purpose of a link using link text combined with its enclosing list item
- H78: Identifying the purpose of a link using link text combined with its enclosing paragraph
- H79: Identifying the purpose of a link in a data table using the link text combined with its enclosing table cell and associated table header cells
- H81: Identifying the purpose of a link in a nested list using link text combined with its parent list item
- F63: Failure of Success Criterion 2.4.4 due to providing link context only in content that is not related to the link
- F89 - providing null alt text on an image that is the only content of a link
- This test checks for actual links, not links whose role has been mapped to other UI elements using ARIA (example role="button").
- This test does not check for missing alt attribute for
<area>tags in image maps, that is covered under SC2-4-4-image-map
|Test name||Link Purpose|
|Success Criterion||2.4.4 Link Purpose (In Context)|
|Test environment||HTML source or DOM|
|Test subject||single web page|
|User expertise and skills||no prior knowledge|
- All anchor tags with an "href" attribute on a webpage, excluding anchor tags that have been mapped to other elements using ARIA roles.
- All elements with a
Step 1 - Check for Accessible Name
- For each link, use the accessible name algorithm to derive the link's accessible name: see HTML to Platform Accessibility APIs Implementation Guide - section 6.10
- If link has an aria-labelledby attribute, the link's accessible name is the value of its associated element.
- Otherwise check for aria-label. If an aria-label attribute is present, the link's accessible name is the text string value of that attribute.
- Otherwise use the link element subtree (value of the link content, if any). This include alt texts for images.
- Otherwise use the link's title attribute.
If none of the above yield a usable text string for the link: return
|ErrorMessage||No accessible name for link.|
else go to Step 2
Step 2 - Check for Uniqueness.
Compare the calculated accessible names (see step 1) of all links on the page. If all accessible names are unique then: Return
else go to Step 3
Step 3 - Check Link Targets
The following data structure is necessary for the remaining steps in this test:
- Create a group of all links whose accessible name is identical. (from here on refered to as a "group item")
- Add the group to a datastructure such as a list or an array.
- Repeat procedure until you have explored all the links on the page.
Now you have a collection of links grouped by their accessible names. In other wordsWithin each group item, all links have the same accessible name. We know we have at least one group item, since we got past Step 2. In the remaining steps we need to check for other factors that may explain why link texts are the same, and determine whether other factors exist that distinguish link texts.
- If all links in a group item point to same resource, they can have the same link text (this step).
- All links within a group item have same accessible name, but their accessible description (created by use of aria-describedby attribute or the title attribute) makes the link text unique (next step).
- All links within a group item have identical accessible names and descriptions, but their programmatic context is sufficient to distinguish them (step 5).
- Links are ambiguous to all users (step 6).
If a group item of links fails all checks, the test fails.
Check if links with identical accessible name go to the same destination. If all links in a group item go to same destination Return
else go to Step 4
Step 4 - Add Accessible Description
For each link in a group of links with identical accessible name: Compute the link´s accessible description (see html to platform guide, section 6.10 as referenced above).
- Look for an aria-describedby attribute on a link. If present add the text of the target note to the link's accessible description node.
- If link has a non-empty title attribute that was not used as its accessible name, add value of the title attribute to the link's accessible description.
Compare links with their accessible names combined with their accessible descriptions. If the combination of accessible name and accessible description uniquely identifies all links in a group item: Return
else go to Step 5
Step 5 - Calculate Context
Explore links together with their programmatically determined link context This includes textual content of:
- Same paragraph as link
- Same list item as link
- Same table cell as link (if table role is not marked with presentation)
- Header cell for link's current table cell (if table is not marked withrole ="presentation")
For each link, construct a variable which contains the link's accessible name, description and context. Repeat the uniqueness check.
If all links in a group item, considered together with their computed accessible description and programatically determinable context are unique: Return
else go to Step 6
Step 6 - Links are ambiguous to All Users
(links may be ambiguous to users in general, need interactive testing). For all remaining links in a given group item, present them to human testers. Ask the testers if they can uniquely identify the purpose of each link within a group from its on-screen location or visible context.
If yes return
|ErrorMessage||Link text, together with description and context, is not sufficient to identify the link purpose.|
else (link text meant to be ambiguous to all users) Return