@@ -44,7 +44,7 @@ This is what accessibility-first testing allows us to achieve. And as a massive
4444 <th>HTML element</th>
4545 </tr>
4646 </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 " >
4848 <%= table_rows([
4949 ["**link**", "`<a href=…>`"],
5050 ["_none_", "`<a>`"],
@@ -69,10 +69,14 @@ This is what accessibility-first testing allows us to achieve. And as a massive
6969 <th>HTML element</th>
7070 </tr>
7171 </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 " >
7373 <%= table_rows([
7474 ["**main**", "`<main>`"],
7575 ["**navigation**", "`<nav>`"],
76+ ["**banner**", "`<header role=banner>`"],
77+ ["**contentinfo**", "`<footer role=contentinfo>`"],
78+ ["**search**", "`<form role=search>`"],
79+ ["**form**", "`<form>`"],
7680 ["**complementary**", "`<aside>`"],
7781 ["**region**", "`<section>`"],
7882 ]) %>
@@ -87,7 +91,7 @@ This is what accessibility-first testing allows us to achieve. And as a massive
8791 <th>HTML element</th>
8892 </tr>
8993 </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 " >
9195 <%= table_rows([
9296 ["**link**", "`<a href=…>`"],
9397 ["_none_", "`<a>`"],
@@ -116,7 +120,7 @@ This is what accessibility-first testing allows us to achieve. And as a massive
116120 <th>HTML element</th>
117121 </tr>
118122 </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 " >
120124 <%= table_rows([
121125 ["**form**", "`<form>`"],
122126 ["**button**", "`<button>`"],
@@ -126,17 +130,17 @@ This is what accessibility-first testing allows us to achieve. And as a massive
126130 ["**textbox**", "`<input type=email>`"],
127131 ["**textbox**", "`<input type=tel>`"],
128132 ["**textbox**", "`<input type=url>`"],
129- ["**searchbox**", "`<input type=search>` with no `list` attribute"],
133+ ["**searchbox**", "`<input type=search>` without `list` attribute"],
130134 ["**radio**", "`<input type=radio>`"],
131135 ["**checkbox**", "`<input type=checkbox>`"],
132- ["**combobox**", "`<select>`"],
136+ ["**combobox**", "`<select>` without `multiple` attribute "],
133137 ["**listbox**", "`<select>` with `multiple` attribute"],
134138 ["**option**", "`<option>`"],
135139 ["**slider**", "`<input type=range>`"],
136140 ["_none_", "`<input type=password>`"],
137141 ["progressbar", "`<progress>`"],
138- ["group", "`<fieldset>`"],
139142 ["status", "`<output>`"],
143+ ["group", "`<fieldset>`"],
140144 ["_none_", "`<legend>`"],
141145 ]) %>
142146 </tbody >
@@ -150,7 +154,7 @@ This is what accessibility-first testing allows us to achieve. And as a massive
150154 <th>HTML element</th>
151155 </tr>
152156 </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 " >
154158 <%= table_rows([
155159 ["**table**", "`<table>`"],
156160 ["**rowgroup**", "`<tbody>`, `<thead>`, `<tfoot>`"],
@@ -162,19 +166,113 @@ This is what accessibility-first testing allows us to achieve. And as a massive
162166 </tbody >
163167</table >
164168
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+
165215## Accessible names
166216
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 .
168218
169219These names are provided by HTML in a number of ways:
170220
171221- ` <label> ` relationship
172222- ` aria-labelledby ` attribute
173223- ` 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
178276
179277- Build components
180278- Test components work as expected
0 commit comments