Rule 6.2.1
Summary
This test consists in checking that there are no empty links in the page
Business description
Criterion
Test
Description
Dans chaque page web, chaque lien a-t-il un intitulé entre
<a>et</a>?
Notes techniques (6.2)
Une ancre n’est pas un lien même si pendant longtemps l’élément
<a>a servi de support à cette technique. Elle n’est donc pas concernée par le présent critère.
Level
A
Technical description
Scope
Page
Decision level
Decidable
Algorithm
Selection
Set1
All <a> tags with a "href" attribute that have neither an "aria-label" attribute nor an "aria-labelledby"
attribute.
All the tags with a "role" attribute equals to “link” that have neither an "aria-label" attribute nor an
"aria-labelledby" attribute.
Process
Test1
For each element of Set1, we compute the link text using LinkTextElementBuilder, which:
- Recursively traverses the children of the link element
- For text nodes: extracts the text content
- For image elements (
<img>,<svg>,<object>,<embed>,<input type="image">,<area>, and elements withrole="img"): delegates toAccessibleNameElementBuilderto compute the accessible name following the RGAA priority order:aria-labelledbyattribute (resolved via DOM lookup)aria-labelattributealtattribute (for<img>,<area>,<input type="image">)<title>child element (for<svg>)titleattribute (for<img>,<input type="image">,<object>,<embed>)- Fallback text content (for
<canvas>,<object>)
- For other elements: recursion continues into child nodes
We then check whether the computed link text is not empty.
For each element returning true in Test1, raise a MessageA
MessageA : Empty Link
- code : EmptyLink
- status: Failed
- parameter : computed accessible name,
"title"attribute, snippet - present in source : yes
Analysis
Not Applicable
The page has no link (Set1 is empty)
Passed
All the links of the page have not empty textual content (Test1 returns false for all the elements of Set1)
Failed
At least one link has an empty textual content (Test1 returns true for at least one element of Set1)
Notes
We exclude tags with an aria-label attribute or an aria-labelledby attribute as we consider that these tags have
an accessible name.
For this test, the "title" attribute on the link element itself is not taken into account to compute the textual
content of the link. It ensures empty links only with a "title" attribute are seen as failed.
Image elements inside links are handled by delegating to AccessibleNameElementBuilder, which follows the RGAA
accessible name computation order. This ensures that SVG images with aria-label, images with aria-labelledby
referencing external text, and other image types are properly accounted for when determining whether a link has
non-empty text.