-
Notifications
You must be signed in to change notification settings - Fork 4
/
tables.html
479 lines (461 loc) · 28.3 KB
/
tables.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
<!DOCTYPE html>
<html lang="en-US">
<head>
<title>Tables</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width"> <link href="css/training.css" rel="stylesheet" type="text/css">
</head>
<body><script> (function(i, s, o, g, r, a, m) {
i['GoogleAnalyticsObject'] = r;
i[r] = i[r] || function() {
(i[r].q = i[r].q || []).push(arguments)
}, i[r].l = 1 * new Date();
a = s.createElement(o), m = s.getElementsByTagName(o)[0];
a.async = 1;
a.src = g;
m.parentNode.insertBefore(a, m)
})(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');
ga('create', 'UA-40224544-1', 'ncsu.edu');
ga('send', 'pageview');</script><a href="#main" title="Skip to main content" class="skip-main">Skip To Main Content</a>
<h1>Tables</h1>
<nav>
<p class="toc">
<label for="toc-menu" class="screen-reader">Table of Contents Menu</label> <select id="toc-menu">
<option value="http://accessibility.oit.ncsu.edu/training/accessibility-handbook/">Table of Contents</option>
<optgroup label="The Nature of What is Required">
<option value="http://accessibility.oit.ncsu.edu/training/accessibility-handbook/understand-nature.html">Overview</option>
<option value="http://accessibility.oit.ncsu.edu/training/accessibility-handbook/what-accessible-means.html">What Accessibility Means</option>
<option value="http://accessibility.oit.ncsu.edu/training/accessibility-handbook/law.html">Accessibility and the Law</option>
<option value="http://accessibility.oit.ncsu.edu/training/accessibility-handbook/ada.html">Americans with Disabilities Act</option>
<option value="http://accessibility.oit.ncsu.edu/training/accessibility-handbook/508.html">Section 508</option>
<option value="http://accessibility.oit.ncsu.edu/training/accessibility-handbook/wcag.html">WCAG 2</option>
<option value="http://accessibility.oit.ncsu.edu/training/accessibility-handbook/vpat.html">VPAT</option>
</optgroup>
<optgroup label="Choose a technology">
<option value="http://accessibility.oit.ncsu.edu/training/accessibility-handbook/technology-overview.html">Overview</option>
<option value="http://accessibility.oit.ncsu.edu/training/accessibility-handbook/technology-html.html">HTML</option>
<option value="http://accessibility.oit.ncsu.edu/training/accessibility-handbook/technology-pdf.html">PDF</option>
<option value="http://accessibility.oit.ncsu.edu/training/accessibility-handbook/technology-office.html">Office Documents</option>
<option value="http://accessibility.oit.ncsu.edu/training/accessibility-handbook/technology-rich-media.html">Rich Media</option>
</optgroup>
<optgroup label="Some Basics">
<option value="http://accessibility.oit.ncsu.edu/training/accessibility-handbook/basics-overview.html">Overview</option>
<option value="http://accessibility.oit.ncsu.edu/training/accessibility-handbook/language.html">Language</option>
<option value="http://accessibility.oit.ncsu.edu/training/accessibility-handbook/valid-code.html">Valid Code</option>
</optgroup>
<optgroup label="Document Structure">
<option value="http://accessibility.oit.ncsu.edu/training/accessibility-handbook/headings.html">Headings</option>
<option value="http://accessibility.oit.ncsu.edu/training/accessibility-handbook/aria-landmarks.html">ARIA Landmarks</option>
<option value="http://accessibility.oit.ncsu.edu/training/accessibility-handbook/lists.html">Lists</option>
<option value="http://accessibility.oit.ncsu.edu/training/accessibility-handbook/tables.html">Tables</option>
</optgroup>
<optgroup label="User Interactions">
<option value="http://accessibility.oit.ncsu.edu/training/accessibility-handbook/mouse-and-keyboard-events.html">Mouse and Keyboard Events</option>
<option value="http://accessibility.oit.ncsu.edu/training/accessibility-handbook/visual-focus.html">Visual Focus</option>
<option value="http://accessibility.oit.ncsu.edu/training/accessibility-handbook/menus.html">Menus</option>
<option value="http://accessibility.oit.ncsu.edu/training/accessibility-handbook/skip-to-main-content.html">Skip to Main Content Links</option>
<option value="http://accessibility.oit.ncsu.edu/training/accessibility-handbook/forms.html">Forms</option>
<option value="http://accessibility.oit.ncsu.edu/training/accessibility-handbook/color-contrast.html">Color Contrast</option>
<option value="http://accessibility.oit.ncsu.edu/training/accessibility-handbook/links.html">Links</option>
<option value="http://accessibility.oit.ncsu.edu/training/accessibility-handbook/link-new-window.html">Links Opening in New Windows</option>
<option value="http://accessibility.oit.ncsu.edu/training/accessibility-handbook/link-text-alt.html">Text or Alt Attribute for Links</option>
<option value="http://accessibility.oit.ncsu.edu/training/accessibility-handbook/link-internal.html">Internal Links</option>
<option value="http://accessibility.oit.ncsu.edu/training/accessibility-handbook/link-behavior.html">Link vs. Button</option>
<option value="http://accessibility.oit.ncsu.edu/training/accessibility-handbook/link-text-descriptive-target.html">Using Descriptive Link Text</option>
<option value="http://accessibility.oit.ncsu.edu/training/accessibility-handbook/link-text-length.html">Length of Link Text</option>
<option value="http://accessibility.oit.ncsu.edu/training/accessibility-handbook/link-text-unique.html">Unique Link Text</option>
<option value="http://accessibility.oit.ncsu.edu/training/accessibility-handbook/link-text-url.html">URL Text</option>
<option value="http://accessibility.oit.ncsu.edu/training/accessibility-handbook/link-underline.html">Underline Style for Links</option>
<option value="http://accessibility.oit.ncsu.edu/training/accessibility-handbook/find-content-multiple.html">Finding Content in Multiple Ways</option>
<option value="http://accessibility.oit.ncsu.edu/training/accessibility-handbook/timed-events.html">Timed Events</option>
<option value="http://accessibility.oit.ncsu.edu/training/accessibility-handbook/aria-checkbox.html">ARIA Checkbox Tutorial</option>
</optgroup>
<optgroup label="Conveying Through Alternate Senses">
<option value="http://accessibility.oit.ncsu.edu/training/accessibility-handbook/alternative-text.html">Alternative Text</option>
<option value="http://accessibility.oit.ncsu.edu/training/accessibility-handbook/captioning.html">Captioning</option>
</optgroup>
<optgroup label="Appendices">
<option value="http://accessibility.oit.ncsu.edu/training/accessibility-handbook/testing-tools.html">Appendix A - Testing Tools</option>
</optgroup>
</select>
<input id="go-button" type="button" value="GO" onclick="location = document.getElementById('toc-menu').options[ document.getElementById('toc-menu').selectedIndex].value;">
</p>
<p class="prev"><a href="http://accessibility.oit.ncsu.edu/training/accessibility-handbook/lists.html"><img src="images/left-arrow.png" alt="previous" />Lists</a></p>
<p class="next"><a href="http://accessibility.oit.ncsu.edu/training/accessibility-handbook/mouse-and-keyboard-events.html">Mouse and Keyboard Events<img src="images/right-arrow.png" alt="next" /></a></p>
</nav><div id="main" role="main" tabindex="-1">
<nav id="page-contents" role="navigation" aria-labelledby="page-contents-heading">
<h2 id="page-contents-heading">Page Contents</h2>
<ul>
<li><a href="#1"><img src="images/checkmark-small.png" alt="Good Technique" title="Good Technique">A simple data table with column and row headings</a></li>
<li><a href="#2"><img src="images/checkmark-small.png" alt="Good Technique" title="Good Technique">A complex data table using header and id attributes</a></li>
<li><a href="#3"><img src="images/checkmark-small.png" alt="Good Technique" title="Good Technique">A layout table</a></li>
<li><a href="#4"><img src="images/x-small.png" alt="Bad Technique" title="Bad Technique">A data table with no headings, but using bold text to mimic headings</a></li>
<li><a href="#5"><img src="images/x-small.png" alt="Bad Technique" title="Bad Technique">A layout table with a summary attribute</a></li>
</ul>
</nav>
<h2>Overview</h2>
<p>Tables are primarily used to present tabular information, however, tables are also still used for creating layouts. While WCAG does not prohibit the use of tables for layouts, it encourages developers to use CSS instead.</p>
<p>Tables used to display tabular information can be divided into two groups - simple layouts and complex layouts. Simple layouts have a single row of headers at the top of the table and/or a single column of headers on the left side of the table. Additionally, there are no merged cells within the table. Complex data tables have either multiple rows or columns of headers, contain merged cells, or contain blank rows or columns for visual effect.</p>
<p>Additionally, data tables must also have a caption or a summary.</p>
<h2>Caption</h2>
<p>The caption element identifies the table. It can be thought of as a title or a heading for a table.</p>
<pre class="code"><table>
<caption>Schedule for the week of March 6</caption>
<tr>
<th scope="col">State & First</th>
<th scope="col">State & Sixth</th>
<th scope="col">State & Fifteenth</th>
<th scope="col">Fifteenth & Morrison</th>
</tr>
<tr>
<td>4:00</td>
<td>4:05</td>
<td>4:11</td>
<td>4:19</td>
</tr>
…
</table>
</pre>
<h2>Summary</h2>
<p>The summary can perform two different functions. It is allowable to have the summary perform both functions at the same time.</p>
<ul>
<li>it can describe the layout of the table to help screen reader users know how to navigate the table</li>
<li>it can describe in narrative form what information the table is trying to convey</li>
</ul>
<pre class="code"><table summary="Schedule for Route 7 going downtown. Service begins
at 4:00 AM and ends at midnight. Intersections are listed in the top row.
Find the intersection closest to your starting point or destination, then read
down that column to find out what time the bus leaves that intersection.">
<tr>
<th scope="col">State & First</th>
<th scope="col">State & Sixth</th>
<th scope="col">State & Fifteenth</th>
<th scope="col">Fifteenth & Morrison</th>
</tr>
<tr>
<td>4:00</td>
<td>4:05</td>
<td>4:11</td>
<td>4:19</td>
</tr>
…
</table></pre>
<div id="correct-simple" class="example good">
<h2 id="1"><img src="images/checkmark-small.png" alt="Good Technique" title="Good Technique" />A simple data table with column and row headings</h2>
<h3>Source Code</h3>
<pre class="code"><table border="1" summary="Pizza sizes are listed in the first row. Types of pizza are listed in the first column. Cross-reference them to determine the price of the pizza.">
<caption>Pizza Prices</caption>
<tr>
<th scope="col">&nbsp;</th>
<th scope="col">Small</th>
<th scope="col">Medum</th>
<th scope="col">Large</th>
</tr>
<tr>
<th scope="row">Cheese</th>
<td>$8</td>
<td>$10</td>
<td>$12</td>
</tr>
<tr>
<th scope="row">Veggie</th>
<td>$10</td>
<td>$12</td>
<td>$14</td>
</tr>
<tr>
<th scope="row">Pepperoni</th>
<td>$10</td>
<td>$12</td>
<td>$14</td>
</tr>
</table></pre>
<h3>Implementation</h3>
<table border="1" summary="Pizza sizes are listed in the first row. Types of pizza are listed in the first column. Cross-reference them to determine the price of the pizza.">
<caption>
Pizza Prices
</caption>
<tr>
<th scope="col"> </th>
<th scope="col">Small</th>
<th scope="col">Medum</th>
<th scope="col">Large</th>
</tr>
<tr>
<th scope="row">Cheese</th>
<td>$8</td>
<td>$10</td>
<td>$12</td>
</tr>
<tr>
<th scope="row">Veggie</th>
<td>$10</td>
<td>$12</td>
<td>$14</td>
</tr>
<tr>
<th scope="row">Pepperoni</th>
<td>$10</td>
<td>$12</td>
<td>$14</td>
</tr>
</table>
</div>
<div id="correct-complex" class="example good">
<h2 id="2"><img src="images/checkmark-small.png" alt="Good Technique" title="Good Technique" />A complex data table using header and id attributes</h2>
<h3>Source Code</h3>
<pre class="code"><table border="1" summary="Pizza toppings are listed in the first two rows. Sizes of pizza are listed in the first column. Cross reference them to determine the price of each topping.">
<caption>Topping Prices</caption>
<tr>
<th scope="col">&nbsp;</th>
<th colspan="3" scope="col" id="meat">Meat Toppings</th>
<th colspan="3" scope="col" id="veg">Vegetable Toppings</th>
</tr>
<tr>
<th scope="col">&nbsp;</th>
<th scope="col" id="pep">Pepperoni</th>
<th scope="col" id="sa">Sausage</th>
<th scope="col" id="bac">Bacon</th>
<th scope="col" id="on">Onion</th>
<th scope="col" id="ol">Olives</th>
<th scope="col" id="tom">Tomato</th>
</tr>
<tr>
<th scope="row" id="sm">Small</th>
<td headers="meat pep sm">$0.80</td>
<td headers="meat sa sm">$0.80</td>
<td headers="meat bac sm">$1.00</td>
<td headers="veg on sm">$0.60</td>
<td headers="veg ol sm">$0.80</td>
<td headers="veg tom sm">$0.60</td>
</tr>
<tr>
<th scope="row" id="med">Medium</th>
<td headers="meat pep med">$1.00</td>
<td headers="meat sa med">$1.00</td>
<td headers="meat bac med">$1.20</td>
<td headers="veg on med">$0.80</td>
<td headers="veg ol med">$1.00</td>
<td headers="veg tom med">$0.80</td>
</tr>
<tr>
<th scope="row" id="lg">Large</th>
<td headers="meat pep lg">$1.20</td>
<td headers="meat sa lg">$1.20</td>
<td headers="meat bac lg">$1.40</td>
<td headers="veg on lg">$1.00</td>
<td headers="veg ol lg">$1.20</td>
<td headers="veg tom lg">$1.00</td>
</tr>
</table></pre>
<h3>Implementation</h3>
<table border="1" summary="Pizza toppings are listed in the first two rows. Sizes of pizza are listed in the first column. Cross reference them to determine the price of each topping.">
<caption>
Topping Prices
</caption>
<tr>
<th scope="col"> </th>
<th colspan="3" scope="col" id="meat">Meat Toppings</th>
<th colspan="3" scope="col" id="veg">Vegetable Toppings</th>
</tr>
<tr>
<th scope="col"> </th>
<th scope="col" id="pep">Pepperoni</th>
<th scope="col" id="sa">Sausage</th>
<th scope="col" id="bac">Bacon</th>
<th scope="col" id="on">Onion</th>
<th scope="col" id="ol">Olives</th>
<th scope="col" id="tom">Tomato</th>
</tr>
<tr>
<th scope="row" id="sm">Small</th>
<td headers="meat pep sm">$0.80</td>
<td headers="meat sa sm">$0.80</td>
<td headers="meat bac sm">$1.00</td>
<td headers="veg on sm">$0.60</td>
<td headers="veg ol sm">$0.80</td>
<td headers="veg tom sm">$0.60</td>
</tr>
<tr>
<th scope="row" id="med">Medium</th>
<td headers="meat pep med">$1.00</td>
<td headers="meat sa med">$1.00</td>
<td headers="meat bac med">$1.20</td>
<td headers="veg on med">$0.80</td>
<td headers="veg ol med">$1.00</td>
<td headers="veg tom med">$0.80</td>
</tr>
<tr>
<th scope="row" id="lg">Large</th>
<td headers="meat pep lg">$1.20</td>
<td headers="meat sa lg">$1.20</td>
<td headers="meat bac lg">$1.40</td>
<td headers="veg on lg">$1.00</td>
<td headers="veg ol lg">$1.20</td>
<td headers="veg tom lg">$1.00</td>
</tr>
</table>
</div>
<div id="correct-layout" class="example good">
<h2 id="3"><img src="images/checkmark-small.png" alt="Good Technique" title="Good Technique" />A layout table</h2>
<h3>Source Code</h3>
<pre class="code"><table width="100%" border="0">
<tr>
<td colspan="2" bgcolor="#c00"><h1 style="color:#fff">Website Logo</h1></td>
</tr>
<tr>
<td width="20%" valign="top" bgcolor="#ccc">
<a href="#">Menu link</a><br>
<a href="#">Menu link</a><br>
<a href="#">Menu link</a><br>
<a href="#">Menu link</a><br>
<a href="#">Menu link</a>
</td>
<td width="80%" valign="top" bgcolor="#fff">
<h1>Welcome to our great site!</h1>
<p>Come find out about all of the great things we do here at our company!</p>
</td>
</tr>
<tr>
<td colspan="2" align="center" height="20" bgcolor="#000"><p style="color:#fff">Contact Info</p></td>
</tr>
</table></pre>
<h3>Implementation</h3>
<table width="100%" border="0">
<tr>
<td colspan="2" bgcolor="#c00"><h1 style="color:#fff">Website Logo</h1></td></tr>
<tr>
<td width="20%" valign="top" bgcolor="#ccc">
<a href="#">Menu link</a><br>
<a href="#">Menu link</a><br>
<a href="#">Menu link</a><br>
<a href="#">Menu link</a><br>
<a href="#">Menu link</a>
</td>
<td width="80%" valign="top" bgcolor="#fff">
<h1>Welcome to our great site!</h1>
<p>Come find out about all of the great things we do here at our company!</p>
</td>
</tr>
<tr>
<td colspan="2" align="center" height="20" bgcolor="#000"><p style="color:#fff">Contact Info</p></td>
</tr>
</table>
</div>
<div id="incorrect-headers" class="example bad">
<h2 id="4"><img src="images/x-small.png" alt="Bad Technique" title="Bad Technique" />A data table with no headings, but using bold text to mimic headings</h2>
<h3>Source Code</h3>
<pre class="code"><table border="1">
<tr>
<td>&nbsp;</td>
<td style="font-weight:bold">Small</td>
<td style="font-weight:bold">Medum</td>
<td style="font-weight:bold">Large</td>
</tr>
<tr>
<td style="font-weight:bold">Cheese</td>
<td>$8</td>
<td>$10</td>
<td>$12</td>
</tr>
<tr>
<td style="font-weight:bold">Veggie</td>
<td>$10</td>
<td>$12</td>
<td>$14</td>
</tr>
<tr>
<td style="font-weight:bold">Pepperoni</td>
<td>$10</td>
<td>$12</td>
<td>$14</td>
</tr>
</table></pre>
<h3>Implementation</h3>
<table border="1">
<tr>
<td> </td>
<td style="font-weight:bold">Small</td>
<td style="font-weight:bold">Medum</td>
<td style="font-weight:bold">Large</td>
</tr>
<tr>
<td style="font-weight:bold">Cheese</td>
<td>$8</td>
<td>$10</td>
<td>$12</td>
</tr>
<tr>
<td style="font-weight:bold">Veggie</td>
<td>$10</td>
<td>$12</td>
<td>$14</td>
</tr>
<tr>
<td style="font-weight:bold">Pepperoni</td>
<td>$10</td>
<td>$12</td>
<td>$14</td>
</tr>
</table>
</div>
<div id="incorrect-layout" class="example bad">
<h2 id="5"><img src="images/x-small.png" alt="Bad Technique" title="Bad Technique" />A layout table with a summary attribute</h2>
<p>When you add the summary attribute to a layout table, screen reader users will have the summary attribute read to them. This is unnecessary and more cumbersome to the user. It is better to simply leave the summary attribute and caption element off.</p>
<h3>Source Code</h3>
<pre class="code"><table width="100%" border="0" summary="a layout table">
<tr>
<td colspan="2" bgcolor="#c00"><h1 style="color:#fff">Website Logo</h1></td>
</tr>
<tr>
<td width="20%" valign="top" bgcolor="#ccc">
<a href="#">Menu link</a><br>
<a href="#">Menu link</a><br>
<a href="#">Menu link</a><br>
<a href="#">Menu link</a><br>
<a href="#">Menu link</a>
</td>
<td width="80%" valign="top" bgcolor="#fff">
<h1>Welcome to our great site!</h1>
<p>Come find out about all of the great things we do here at our company!</p>
</td>
</tr>
<tr>
<td colspan="2" align="center" height="20" bgcolor="#000"><p style="color:#fff">Contact Info</p></td>
</tr>
</table></pre>
<h3>Implementation</h3>
<table width="100%" border="0" summary="a layout table">
<tr>
<td colspan="2" bgcolor="#c00"><h1 style="color:#fff">Website Logo</h1></td></tr>
<tr>
<td width="20%" valign="top" bgcolor="#ccc">
<a href="#">Menu link</a><br>
<a href="#">Menu link</a><br>
<a href="#">Menu link</a><br>
<a href="#">Menu link</a><br>
<a href="#">Menu link</a>
</td>
<td width="80%" valign="top" bgcolor="#fff">
<h1>Welcome to our great site!</h1>
<p>Come find out about all of the great things we do here at our company!</p>
</td>
</tr>
<tr>
<td colspan="2" align="center" height="20" bgcolor="#000"><p style="color:#fff">Contact Info</p></td>
</tr>
</table>
</div>
<div>
<h2>Further Reading</h2>
<ul>
<li><a href="http://webaim.org/techniques/tables/">WebAIM: Creating Accessible Tables</a></li>
<li><a href="http://www.w3.org/TR/WCAG20-TECHS/H73.html">W3C: Summary Attribute Technique</a></li>
<li><a href="http://www.w3.org/TR/WCAG20-TECHS/F46.html">W3C: Correctly Making Layout Tables</a></li>
<li><a href="http://www.w3.org/TR/WCAG20-TECHS/H43.html">W3C: Table Header and ID Attributes</a></li>
<li><a href="http://www.w3.org/TR/WCAG20-TECHS/H51.html">W3C: Presenting Tabular Information</a></li>
<li><a href="http://www.w3.org/TR/WCAG20-TECHS/H63.html">W3C: Table Scope Attribute</a></li>
</ul>
</div>
</div></body>
</html>