| id | 2ee8b8 | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| name | Visible label is part of accessible name | ||||||||||||||||||||
| rule_type | atomic | ||||||||||||||||||||
| description | This rule checks that interactive elements labeled through content have their visible label as part of their accessible name. | ||||||||||||||||||||
| accessibility_requirements |
|
||||||||||||||||||||
| input_aspects |
|
||||||||||||||||||||
| acknowledgments |
|
This rule applies to any element for which all the following is true:
- The element has a semantic role that is a widget that supports name from content; and
- The element has visible text content; and
- The element has an
aria-labeloraria-labelledbyattribute.
For each target element, all text nodes in the visible text content match characters and are contained within the accessible name of this target element, except for characters in the text nodes used to express non-text content. Leading and trailing whitespace and difference in case sensitivity should be ignored.
This rule assumes that all resources needed for rendering the page are properly loaded. Checking if resources are missing is out of the scope of rules. Missing resources may be rendered as text (for example, missing img are rendered as their alt attribute).
Implementation of Presentational Roles Conflict Resolution varies from one browser or assistive technology to another. Depending on this, some elements can have one of the applicable semantic roles and fail this rule with some technology but users of other technologies would not experience any accessibility issue.
This rule applies to elements with a widget role that support name from content. This includes the following: button, checkbox, gridcell, link, menuitem, menuitemcheckbox, menuitemradio, option, radio, searchbox, switch, tab, treeitem.
The understanding document of 2.5.3 Label in Name use the term "symbolic text characters" to refer to a type of non-text content that uses text characters as symbols, such as using "x" to mean "close". This rule considers them as "characters expressing non-text content". Unicode emojis are another example of characters expressing non-text content, although these are not "symbolic text characters".
- Understanding Success Criterion 2.5.3: Label in Name
- G208: Including the text of the visible label as part of the accessible name
This link has visible text that matches the accessible name.
<a href="https://act-rules.github.io/" aria-label="ACT rules">ACT rules</a>This link has visible text that, ignoring trailing whitespace, matches the accessible name.
<a href="https://act-rules.github.io/" aria-label=" ACT rules ">ACT rules</a>This link has visible text that, ignoring case, matches the accessible name.
<a href="https://act-rules.github.io/" aria-label="act rules">ACT rules</a>This button has visible text that is contained within the accessible name.
<button aria-label="Next Page in the list">Next Page</button>This button has visible text that does not need to be contained within the accessible name, because the "x" text node is non-text content. Note: this would need to meet SC 1.1.1 Non text content.
<button aria-label="anything">X</button>This button element has the text "search" rendered as an magnifying glass icon by the font. Because the text is rendered as non-text content, the text does not need to be contained within the accessible name.
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet" />
<style>
button {
font-family: 'Material Icons';
}
</style>
<button aria-label="Find">search</button>This link has visible text that is different from the accessible name.
<a href="https://act-rules.github.io/" aria-label="WCAG">ACT rules</a>This button has visible text that is only partially contained within the accessible name.
<button aria-label="the full">The full label</button>This link has visible text with mathematical symbols, that does not match the accessible name because the mathematical symbols were written out in the accessible name. This is explicitly mentioned in WCAG.
<a href="/" aria-label="Proof of two multiplied by two is four">Proof of 2×2=4</a>This link has visible text does not match the accessible name because there is a hyphen in the accessible name.
<a href="#" aria-label="non-standard">nonstandard</a>This link has visible text does not match the accessible name because there are extra spaces in the accessible name.
<a aria-label="1 2 3. 4 5 6. 7 8 9 0" href="tel:1234567890">123.456.7890</a>This nav is not a widget, so the visible text does not need to match the accessible name.
<nav aria-label="main nav">W3C navigation</nav>This email text field does not need to have its visible text match the accessible name. The content of a textfield shows its value instead of its label; it does not support name from content. The label is usually adjacent to the textfield instead.
<div>E-mail</div>
<input type="email" aria-label="E-mail" value="Contact" />This div element does not have a widget role, so the visible text does not need to match the accessible name.
<div role="tooltip" aria-label="OK">Next</div>This link has no visible text content.
<a href="https://w3.org" aria-label="W3C homepage">
<img src="/test-assets/shared/w3c-logo.png" alt="w3c logo" />
</a>Details
## Boundary ExamplesThese examples are not normative and not require for consistent implementations. They illustrate limitations and boundaries of the rule. Passed and Inapplicable examples in this category are likely to fail the rule's accessibility requirement, showing how the rule is only a partial test. Testing tools and methodologies are encouraged to be more clever than the rule, and to report the correct outcome for these examples. Therefore, they are not required for consistent implementation.
These buttons have text nodes that qualify as non-text content and therefore pass this rule. The accessible names are not descriptive, thus they fail Success Criterion 1.1.1 Non-Text Content.
<button aria-label="Save"><</button>
<button aria-label="Close">></button>
<button aria-label="Hello world">X</button>