@@ -44,7 +44,7 @@ This is what accessibility-first testing allows us to achieve. And as a massive
44
44
<th>HTML element</th>
45
45
</tr>
46
46
</thead >
47
- <tbody class =" text-white bg-teal -900 border border-teal -700 " >
47
+ <tbody class =" text-white bg-purple -900 border border-purple -700 " >
48
48
<%= table_rows([
49
49
["**link**", "`<a href=…>`"],
50
50
["_none_", "`<a>`"],
@@ -69,10 +69,14 @@ This is what accessibility-first testing allows us to achieve. And as a massive
69
69
<th>HTML element</th>
70
70
</tr>
71
71
</thead >
72
- <tbody class =" text-white bg-teal -900 border border-teal -700 " >
72
+ <tbody class =" text-white bg-purple -900 border border-purple -700 " >
73
73
<%= table_rows([
74
74
["**main**", "`<main>`"],
75
75
["**navigation**", "`<nav>`"],
76
+ ["**banner**", "`<header role=banner>`"],
77
+ ["**contentinfo**", "`<footer role=contentinfo>`"],
78
+ ["**search**", "`<form role=search>`"],
79
+ ["**form**", "`<form>`"],
76
80
["**complementary**", "`<aside>`"],
77
81
["**region**", "`<section>`"],
78
82
]) %>
@@ -87,7 +91,7 @@ This is what accessibility-first testing allows us to achieve. And as a massive
87
91
<th>HTML element</th>
88
92
</tr>
89
93
</thead >
90
- <tbody class =" text-white bg-teal -900 border border-teal -700 " >
94
+ <tbody class =" text-white bg-purple -900 border border-purple -700 " >
91
95
<%= table_rows([
92
96
["**link**", "`<a href=…>`"],
93
97
["_none_", "`<a>`"],
@@ -116,7 +120,7 @@ This is what accessibility-first testing allows us to achieve. And as a massive
116
120
<th>HTML element</th>
117
121
</tr>
118
122
</thead >
119
- <tbody class =" text-white bg-teal -900 border border-teal -700 " >
123
+ <tbody class =" text-white bg-purple -900 border border-purple -700 " >
120
124
<%= table_rows([
121
125
["**form**", "`<form>`"],
122
126
["**button**", "`<button>`"],
@@ -126,17 +130,17 @@ This is what accessibility-first testing allows us to achieve. And as a massive
126
130
["**textbox**", "`<input type=email>`"],
127
131
["**textbox**", "`<input type=tel>`"],
128
132
["**textbox**", "`<input type=url>`"],
129
- ["**searchbox**", "`<input type=search>` with no `list` attribute"],
133
+ ["**searchbox**", "`<input type=search>` without `list` attribute"],
130
134
["**radio**", "`<input type=radio>`"],
131
135
["**checkbox**", "`<input type=checkbox>`"],
132
- ["**combobox**", "`<select>`"],
136
+ ["**combobox**", "`<select>` without `multiple` attribute "],
133
137
["**listbox**", "`<select>` with `multiple` attribute"],
134
138
["**option**", "`<option>`"],
135
139
["**slider**", "`<input type=range>`"],
136
140
["_none_", "`<input type=password>`"],
137
141
["progressbar", "`<progress>`"],
138
- ["group", "`<fieldset>`"],
139
142
["status", "`<output>`"],
143
+ ["group", "`<fieldset>`"],
140
144
["_none_", "`<legend>`"],
141
145
]) %>
142
146
</tbody >
@@ -150,7 +154,7 @@ This is what accessibility-first testing allows us to achieve. And as a massive
150
154
<th>HTML element</th>
151
155
</tr>
152
156
</thead >
153
- <tbody class =" text-white bg-teal -900 border border-teal -700 " >
157
+ <tbody class =" text-white bg-purple -900 border border-purple -700 " >
154
158
<%= table_rows([
155
159
["**table**", "`<table>`"],
156
160
["**rowgroup**", "`<tbody>`, `<thead>`, `<tfoot>`"],
@@ -162,19 +166,113 @@ This is what accessibility-first testing allows us to achieve. And as a massive
162
166
</tbody >
163
167
</table >
164
168
169
+ <table class =" text-left table-fixed " >
170
+ <caption class =" text-2xl " >Tabs</caption >
171
+ <thead >
172
+ <tr>
173
+ <th style="width: 12em">Role name</th>
174
+ <th>HTML element</th>
175
+ </tr>
176
+ </thead >
177
+ <tbody class =" text-white bg-purple-900 border border-purple-700 " >
178
+ <%= table_rows([
179
+ ["**tablist**", "`<ul role=tablist>`"],
180
+ ["**tab**", "`<button role=tab>`"],
181
+ ["**tabpanel**", "`<section role=tabpanel>`"],
182
+ ]) %>
183
+ </tbody >
184
+ <tfoot class =" text-purple-100 bg-purple-900 border border-purple-700 " >
185
+ <tr>
186
+ <td colspan=2 class="px-3 py-1"><em>Should</em> manage focus with JavaScript.</td>
187
+ </tr>
188
+ </tfoot >
189
+ </table >
190
+
191
+ <table class =" text-left table-fixed " >
192
+ <caption class =" text-2xl " >Menus</caption >
193
+ <thead >
194
+ <tr>
195
+ <th style="width: 12em">Role name</th>
196
+ <th>HTML element</th>
197
+ </tr>
198
+ </thead >
199
+ <tbody class =" text-white bg-purple-900 border border-purple-700 " >
200
+ <%= table_rows([
201
+ ["**menu**", "`<ul role=menu>`"],
202
+ ["**menuitem**", "`<button role=menuitem>`"],
203
+ ["**menuitemcheckbox**", "`<button role=menuitemcheckbox>`"],
204
+ ["**menuitemradio**", "`<button role=menuitemradio>`"],
205
+ ["**menubar**", "`<nav role=menubar>`"],
206
+ ]) %>
207
+ </tbody >
208
+ <tfoot class =" text-purple-100 bg-purple-900 border border-purple-700 " >
209
+ <tr>
210
+ <td colspan=2 class="px-3 py-1"><em>Should</em> manage focus with JavaScript.</td>
211
+ </tr>
212
+ </tfoot >
213
+ </table >
214
+
165
215
## Accessible names
166
216
167
- Accessible elements don’t just have a role. They have a name too, which differentiates them from things with the same role.
217
+ Accessible elements don’t just have a role. They can have a ‘ name’ too, which helps the user tell elements with the same role apart .
168
218
169
219
These names are provided by HTML in a number of ways:
170
220
171
221
- ` <label> ` relationship
172
222
- ` aria-labelledby ` attribute
173
223
- ` aria-label ` attribute
174
-
175
- ## Behavior and markup > implementation details
176
-
177
- ## Accessibility-first testing: a standard-based approach
224
+ - The displayed value
225
+ - The text content
226
+
227
+ The algorithm is specified in [ W3C’s Accessible Name and Description Computation] ( https://www.w3.org/TR/accname-1.1/#mapping_additional_nd_te ) .
228
+
229
+ ### Examples of accessible names
230
+
231
+ ``` html
232
+ <button >Save</button >
233
+ ```
234
+
235
+ ``` html
236
+ <label >Email: <input type =email ></label >
237
+ ```
238
+
239
+ ``` html
240
+ <label ><input type =checkbox > Receive email alerts</label >
241
+ ```
242
+
243
+ ``` html
244
+ <article aria-labelledby =" faq-heading" >
245
+ <h2 id =" faq-heading" >Frequently Asked Questions</h2 >
246
+ </article >
247
+ ```
248
+
249
+ ``` html
250
+ <nav aria-label =" Primary" >
251
+ …
252
+ </nav >
253
+ ```
254
+
255
+ ``` html
256
+ <svg role =" img" >
257
+ <title >New document</title >
258
+ …
259
+ </svg >
260
+ ```
261
+
262
+ You could query these elements using Testing Library:
263
+
264
+ ``` ts
265
+ getByRole (' button' , { name: ' Save' });
266
+ getByRole (' textbox' , { name: / Email/ });
267
+ getByRole (' checkbox' , { name: / Receive email alerts/ i });
268
+ getByRole (' article' , { name: ' Frequently asked questions' });
269
+ getByRole (' navigation' , { name: ' Primary' });
270
+ getByRole (' img' , { name: ' New document' });
271
+ ```
272
+
273
+ ----
274
+
275
+ ## Accessibility-first testing: a standards-based approach
178
276
179
277
- Build components
180
278
- Test components work as expected
0 commit comments