Skip to content

Commit 2317ecf

Browse files
Create aria-required-accessible-name-gp8n89.md
1 parent 24a9bcd commit 2317ecf

File tree

1 file changed

+278
-0
lines changed

1 file changed

+278
-0
lines changed
Lines changed: 278 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,278 @@
1+
---
2+
id: gp8n89
3+
name: ARIA required accessible name
4+
rule_type: atomic
5+
description: |
6+
This rule checks that WAI-ARIA accessible name is available when required.
7+
accessibility_requirements:
8+
aria12:accessible_name_required:
9+
title: ARIA 1.2, Accessible Name Required
10+
forConformance: true
11+
failed: not satisfied
12+
passed: satisfied
13+
inapplicable: satisfied
14+
wcag20:1.3.1: # Info and Relationships (A)
15+
secondary: This success criterion is **less strict** than this rule. Unlike WCAG, which might not mandate accessible names for certain elements like table elements, this rule requires them. Consequently, some of the failed examples satisfy this success criterion.
16+
wcag20:2.4.4: # Link Purpose (In Context) (A)
17+
secondary: This success criterion is **related** to this rule. This is because elements assigned the ARIA role of `link` necessitate an accessible name according to WCAG standards. Some of the examples that both passed and failed overlap with this success criterion.
18+
wcag20:2.4.9: # Link Purpose (Link Only) (AAA)
19+
secondary: This success criterion is **related** to this rule. This is because elements assigned the ARIA role of `link` necessitate an accessible name according to WCAG standards. Some of the examples that both passed and failed overlap with this success criterion.
20+
wcag20:4.1.2: # Name, Role, Value (A)
21+
secondary: This success criterion is **related** to this rule. This is because elements assigned an ARIA role corresponding to a user interface component necessitate an accessible name according to WCAG standards. Some of the examples that both passed and failed overlap with this success criterion.
22+
input_aspects:
23+
- Accessibility Tree
24+
- CSS styling
25+
- DOM Tree
26+
- ARIA
27+
acknowledgments:
28+
authors:
29+
- Giacomo Petri
30+
---
31+
32+
## Applicability
33+
34+
This rule applies to any [HTML or SVG element][] that is [included in the accessibility tree][] and has a [WAI-ARIA 1.2][aria 1.2] [explicit semantic role][] that requires an [accessible name][] either from the [author](https://www.w3.org/TR/wai-aria-1.2/#namefromauthor) or the [content](https://www.w3.org/TR/wai-aria-1.2/#namefromcontent), unless the element [implicit semantic role][] matches its [explicit semantic role][].
35+
36+
## Expectation
37+
38+
Each target element has an [accessible name][] that is not empty (`""`).
39+
40+
## Assumptions
41+
42+
There are no assumptions.
43+
44+
## Accessibility Support
45+
46+
Elements with [explicit semantic role][] of `heading` and with no [accessible name][] seem to be consistently ignored by assistive technologies. Nonetheless, in the context of this rule, they fail since [WAI-ARIA 1.2][aria 1.2] mandates the presence of an [accessible name][].
47+
48+
The [accessible name and description computation][] suggests that if an `aria-labelledby` attribute refers to an existing but empty element, the computation should stop and return an empty name without defaulting to the next steps. Several user agents and assistive technologies chose to use the next step in the computation in this case (ultimately defaulting to the content).
49+
50+
## Background
51+
52+
The applicability of this rule is limited to elements that have an [explicit semantic role][] that is not identical to their [implicit semantic role][]. Both [WAI-ARIA 1.2][aria 1.2] and [ARIA in HTML](https://www.w3.org/TR/html-aria/#docconformance) discourage authors from using ARIA when the host language provides a fetaure with equivalent role semantics and values.
53+
54+
An example of an element that has an [implicit semantic role][] that is identical to its [explicit semantic role][] is a `<table role="table">` element. These elements are not applicable because they have extra requirements and should thus be checked separately.
55+
56+
Elements subjected to the [Presentational Roles Conflict Resolution][] are not covered by this rule, since their [explicit semantic role][] of `none` or `presentation` do not require an accessible name. However, if the [Presentational Roles Conflict Resolution][] is invoked, although the rule doesn't apply, an accessible name might still be necessary.
57+
58+
### Bibliography
59+
60+
- [WAI-ARIA 1.2][aria 1.2]
61+
- [ARIA in HTML](https://www.w3.org/TR/html-aria/#docconformance)
62+
- [Understanding Success Criterion 1.3.1: Info and Relationships](https://www.w3.org/WAI/WCAG22/Understanding/name-role-value)
63+
- [Understanding Success Criterion 4.1.2: Name, Role, Value](https://www.w3.org/WAI/WCAG22/Understanding/name-role-value)
64+
65+
## Test Cases
66+
67+
### Passed
68+
69+
#### Passed Example 1
70+
71+
The `div` element with role `button` has an [accessible name][] provided by its content.
72+
73+
```html
74+
<div role="button" tabindex="0">Submit</button>
75+
```
76+
77+
#### Passed Example 2
78+
79+
The `div` element with role `img` has an [accessible name][] provided by the `aria-label` [attribute value][].
80+
81+
```html
82+
<div role="img" aria-label="Rating: 5 out of 5 stars">
83+
<span aria-hidden="true">★★★★★</span>
84+
</div>
85+
```
86+
87+
#### Passed Example 3
88+
89+
The `div` element with role `checkbox` has an [accessible name][] provided thanks to the `aria-labelledby` attribute.
90+
91+
```html
92+
<div role="checkbox" aria-checked="false" tabindex="0" aria-labelledby="passed-example-3"></div>
93+
<div id="passed-example-3">I agree with terms and conditions</div>
94+
```
95+
96+
#### Passed Example 4
97+
98+
The `div` element with role `dialog` has an [accessible name][] provided by the `aria-labelledby` attribute.
99+
100+
```html
101+
<div role="dialog" aria-modal="true" tabindex="-1" aria-labelledby="passed-example-4">
102+
<h1 id="passed-example-4">Terms</h1>
103+
<p>These are our terms.</p>
104+
</div>
105+
```
106+
107+
#### Passed Example 5
108+
109+
The `div` element with role `heading` has an [accessible name][] provided by its content.
110+
111+
```html
112+
<h1>Terms</h1>
113+
```
114+
115+
#### Passed Example 6
116+
117+
This `div` element with role `heading` is not [visible][], but is still [included in the accessibility tree][]. It has a non-empty [accessible name][] provided by its content.
118+
119+
```html
120+
<div role="heading" aria-level="1" style="position: absolute; left: -9999px">ACT rules</div>
121+
```
122+
123+
#### Passed Example 7
124+
125+
The `div` element with role `link` has an [accessible name][] provided by its content.
126+
127+
```html
128+
<div role="link" tabindex="0" onclick="location.href='https://act-rules.github.io/'">ACT Rules</button>
129+
```
130+
131+
### Failed
132+
133+
#### Failed Example 1
134+
135+
The `div` element with role `button` doesn't have an [accessible name][].
136+
137+
```html
138+
<div role="button"></div>
139+
```
140+
141+
#### Failed Example 2
142+
143+
The `div` element with role `img` doesn't have an [accessible name][].
144+
145+
```html
146+
<div role="img">
147+
<span aria-hidden="true">★★★★★</span>
148+
</div>
149+
```
150+
151+
#### Failed Example 3
152+
153+
The `div` element with role `checkbox` doesn't have an [accessible name][].
154+
155+
```html
156+
<div role="checkbox" aria-checked="false" tabindex="0"></div>
157+
<div>I agree with terms and conditions</div>
158+
```
159+
160+
#### Failed Example 4
161+
162+
The `dialog` role accept an [accessible name][] only from the author and not from its content. Therefore, the `div` element with role `dialog` doesn't have an [accessible name][].
163+
164+
```html
165+
<div role="dialog" aria-modal="true" tabindex="-1">
166+
<h1>Terms</h1>
167+
<p>These are our terms.</p>
168+
</div>
169+
```
170+
171+
#### Failed Example 5
172+
173+
The `div` element with role `heading` doesn't an [accessible name][] due to the empty `aria-label` [attribute value][].
174+
175+
```html
176+
<div role="heading" aria-level="1" aria-label="">Terms</h1>
177+
```
178+
179+
#### Failed Example 6
180+
181+
The `div` element with role `heading` has an empty [accessible name][] given by its `aria-labelledby` attribute.
182+
183+
```html
184+
<span id="failed-example-3"></span>
185+
<h1 aria-labelledby="failed-example-3">ACT Rules</h1>
186+
```
187+
188+
#### Failed Example 7
189+
190+
The `div` element with role `button` has an empty [accessible name][] because the `value` attribute does not count in the computation of the [accessible name][].
191+
192+
```html
193+
<div role="button" value="test"></div>
194+
```
195+
196+
#### Failed Example 8
197+
198+
This `div` element with role `button` is not [visible][], but is still [included in the accessibility tree][]. It doesn't have an [accessible name][], therefore failing the rule.
199+
200+
```html
201+
<div role="button" style="position: absolute; left: -9999px" tabindex="0"></div>
202+
```
203+
204+
#### Failed Example 9
205+
206+
The `div` element with role `link` has an empty [accessible name][].
207+
208+
```html
209+
<div role="link" tabindex="0" onclick="location.href='https://act-rules.github.io/'"></button>
210+
```
211+
212+
### Inapplicable
213+
214+
#### Inapplicable Example 1
215+
216+
This `button` element has no [explicit semantic role][].
217+
218+
```html
219+
<button>Submit</button>
220+
```
221+
222+
#### Inapplicable Example 2
223+
224+
This `div` element is not [included in the accessibility tree][], hence its [explicit semantic role][] is not relevant.
225+
226+
```html
227+
<div role="button" style="display:none;"></div>
228+
```
229+
230+
#### Inapplicable Example 3
231+
232+
This `table` element has an [explicit semantic role][] of `table`, that is identical to its [implicit semantic role][].
233+
234+
```html
235+
<table role="table">
236+
<thead>
237+
<tr>
238+
<th>Table Header 1</th>
239+
<th>Table Header 2</th>
240+
</tr>
241+
</thead>
242+
<tbody>
243+
<tr>
244+
<td>Some content 1</td>
245+
<td>Some content 2</td>
246+
</tr>
247+
<tr>
248+
<td>Some content 3</td>
249+
<td>Some content 4</td>
250+
</tr>
251+
</tbody>
252+
</table>
253+
```
254+
255+
#### Inapplicable Example 4
256+
257+
This `div` element has an [explicit semantic role][] of `group`, which does not require an [accessible name][].
258+
259+
```html
260+
<div role="group">Some content</div>
261+
```
262+
263+
#### Inapplicable Example 5
264+
265+
This `button` element has an [explicit semantic role][] of `none`. Although the [Presentational Roles Conflict Resolution][] requires the author to provide an [accessible name][], the [explicit semantic role][] does not require an [accessible name][] for this rule.
266+
267+
```html
268+
<button role="none"></button>
269+
```
270+
271+
[accessible name]: #accessible-name 'Definition of accessible name'
272+
[attribute value]: #attribute-value 'Definition of attribute value'
273+
[explicit semantic role]: #explicit-role 'Definition of Explicit Role'
274+
[implicit semantic role]: #implicit-role 'Definition of Implicit Role'
275+
[included in the accessibility tree]: #included-in-the-accessibility-tree 'Definition of Included in the Accessibility Tree'
276+
[presentational roles conflict resolution]: https://www.w3.org/TR/wai-aria-1.2/#conflict_resolution_presentation_none 'Presentational Roles Conflict Resolution'
277+
[wai-aria 1.2]: https://www.w3.org/TR/wai-aria-1.2/
278+
[html or svg element]: #namespaced-element

0 commit comments

Comments
 (0)