-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtables.html
More file actions
284 lines (279 loc) · 9.33 KB
/
tables.html
File metadata and controls
284 lines (279 loc) · 9.33 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<title>Table Examples</title>
<link rel="stylesheet" type="text/css" href="/stylesheets/tooltips_stylesheet.css">
<style>
.noBorder {
border: none !important;
}
table, th, td {
border: 1px solid black;
text-align:center;
padding: 2px;
}
table {
border-collapse: collapse;
}
tr:nth-child(even){
background-color: #afceff;
}
#columnHeaders {
background-color: #ced3db;
}
.offScreen {
position: absolute!important;
clip: rect(1px 1px 1px 1px)!important;
clip: rect(1px, 1px, 1px, 1px)!important;
clip-path: inset(50%)!important;
padding: 0!important;
border: 0!important;
height: 1px!important;
width: 1px!important;
overflow: hidden!important;
white-space: nowrap!important;
}
.table {
display: table;
}
.table-row {
display: table-row;
}
.table-cell {
display: table-cell;
padding: 10px;
border: 1px solid black;
}
.table-row:nth-child(even) {
background: lightblue;
}
#wrapper {
width: 70%;
margin-left: auto;
margin-right: auto;
}
</style>
<script src="/javascripts/tooltips_javascript.js"></script>
</head>
<body>
<div style="width: 100%; text-align: center;">
<h1>Tables</h1>
</div>
<div id="wrapper">
<h2>Basic Data Table</h2>
<p>This is a basic data table with both column headers and row headers.</p>
<table>
<thead>
<tr id="columnHeaders">
<th scope="col">Account ID</th>
<th scope="col">Information</th>
<th scope="col">Accunt Owner</th>
<th scope="col">Account Opening Date</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">1234</th>
<td>Some inforation about this account</td>
<td>John Doe</td>
<td>April 1, 1980</td>
</tr>
<tr>
<th scope="row">2345</th>
<td>Information about this account</td>
<td>Jane Doe</td>
<td>Mar 17, 1985</td>
</tr>
<tr>
<th scope="row">3456</th>
<td>More account information</td>
<td>Jim Doe</td>
<td>Jul 04, 1987</td>
</tr>
<tr>
<th scope="row">4567</th>
<td>This is also informative</td>
<td>Jessica Doe</td>
<td>Feb 14, 1982</td>
</tr>
</tbody>
</table>
<p>The HTML:</p>
<pre class="prettyprint">
<table>
<thead>
<tr id="columnHeaders">
<th scope="col">Account ID</th>
<th scope="col">Information</th>
<th scope="col">Accunt Owner</th>
<th scope="col">Account Opening Date</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">1234<</th>
<td>Some inforation about this account</td>
<td>John Doe</td>
<td>April 1, 1980</td>
</tr>
<tr>
<th scope="row">2345</th>
<td>Information about this account</td>
<td>Jane Doe</td>
<td>Mar 17, 1985</td>
</tr>
<tr>
<th scope="row">3456</th>
<td>More account information</td>
<td>Jim Doe</td>
<td>Jul 04, 1987</td>
</tr>
<tr>
<th scope="row">4567</th>
<td>This is also informative</td>
<td>Jessica Doe</td>
<td>Feb 14, 1982</td>
</tr>
</tbody>
</table>
</pre>
<p>It's important not to leave table header cells blank. This does not provide context when navigating to columns with screen readers.It's also important to maintain the structure of the table. If a cell has no data, for example, the row must still have the same amount of cells as other rows to maintain the table structure. Otherwise, screen readers may not properly associate headers will the correct corresponding cell.</p>
<table>
<thead>
<tr id="columnHeaders">
<th scope="col" class="offScreen">Row Number</th>
<th scope="col">Information</th>
<th scope="col">Accunt Owner</th>
<th scope="col">Account Opening Date</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">1</th>
<td>Some inforation about this account</td>
<td>John Doe</td>
<td>April 1, 1980</td>
</tr>
<tr>
<th scope="row">2</th>
<td>Information about this account</td>
<td>Jane Doe</td>
<td>Mar 17, 1985</td>
</tr>
<tr>
<th scope="row">3</th>
<td>More account information</td>
<td>Jim Doe</td>
<td>Jul 04, 1987</td>
</tr>
<tr>
<th scope="row">4</th>
<td>This is also informative</td>
<td>Jessica Doe</td>
<td>Feb 14, 1982</td>
</tr>
</tbody>
</table>
<h2>Layout Table</h2>
<p>This is a table that is used for layout. The ARIA role="presentation" role is applied to the <table> element to ensure the table structure is not conveyed by assistive technology such as screen readers.</p>
<table role="presentation" class="noBorder">
<tbody>
<tr>
<td class="noBorder">This table</td>
<td class="noBorder">is used for layout only</td>
<td class="noBorder">and does not contain tabular information.</td>
</tr>
<tr style="background: #FFF;">
<td class="noBorder">For these, we don't</td>
<td class="noBorder">want to convey</td>
<td class="noBorder">the table structure to screen readers.</td>
</tr>
<tr>
<td class="noBorder">To ensure the table</td>
<td class="noBorder">markup is not conveyed,</td>
<td class="noBorder">we use role="presentation".</td>
</tr>
</tbody>
</table>
<pre class="prettyprint">
<table role="presentation" class="noBorder">
<tbody>
<tr>
<td class="noBorder">This table</td>
<td class="noBorder">is used for layout only</td>
<td class="noBorder">and does not contain tabular information.</td>
</tr">
<tr style="background: #FFF;"">
<td class="noBorder">For these, we don't</td>
<td class="noBorder">want to convey</td>
<td class="noBorder">the table structure to screen readers.</td>
</tr>
<tr>
<td class="noBorder">To ensure the table</td>
<td class="noBorder">markup is not conveyed</td>
<td class="noBorder">we use role="presentation".</td>
</tr>
</tbody>
</table>
</pre>
<h2>ARIA Table</h2>
<p>This table uses <div> elements to create cells and CSS to style the columns and rows. HTML <table> markup was not used. To create the necessary roles, ARIA markup is used. The following roles are used:</p>
<ul>
<li>The <a href="https://www.w3.org/TR/wai-aria-1.2/#table">Table</a> role</li>
<li>The <a href="https://www.w3.org/TR/wai-aria-1.2/#row">Row</a> role</li>
<li>The <a href="https://www.w3.org/TR/wai-aria-1.2/#cell">Cell</a> role</li>
<li>The <a href="https://www.w3.org/TR/wai-aria-1.2/#columnheader">Columnheader</a> role</li>
</ul>
<div class="table" role="table">
<div class="table-row" role="row">
<div class="table-cell" role="columnheader">Header 1</div>
<div class="table-cell" role="columnheader">Header 2</div>
<div class="table-cell" role="columnheader">Header 3</div>
</div>
<div class="table-row" role="row">
<div class="table-cell" role="cell">1</div>
<div class="table-cell" role="cell">2</div>
<div class="table-cell" role="cell">3</div>
</div>
<div class="table-row" role="row">
<div class="table-cell" role="cell">4</div>
<div class="table-cell" role="cell">5</div>
<div class="table-cell" role="cell">6</div>
</div>
<div class="table-row" role="row">
<div class="table-cell" role="cell">7</div>
<div class="table-cell" role="cell">8</div>
<div class="table-cell" role="cell">9</div>
</div>
</div>
<pre class="prettyprint">
<div class="table" role="table">
<div class="table-row" role="row">
<div class="table-cell" role="columnheader">Header 1</div>
<div class="table-cell" role="columnheader">Header 2</div>
<div class="table-cell" role="columnheader">Header 3</div>
</div>
<div class="table-row" role="row">
<div class="table-cell" role="cell">1</div>
<div class="table-cell" role="cell">2</div>
<div class="table-cell" role="cell">3</div>
</div>
<div class="table-row" role="row">
<div class="table-cell" role="cell">4</div>
<div class="table-cell" role="cell">5</div>
<div class="table-cell" role="cell">6</div>
</div>
<div class="table-row" role="row">
<div class="table-cell" role="cell">7</div>
<div class="table-cell" role="cell">8</div>
<div class="table-cell" role="cell">9</div>
</div>
</div>
</pre>
</div>
<footer>
<a href="http://robertjmccaffery.com/examples.html">Back to Examples</a> | <a href="http://robertjmccaffery.com/">Home</a>
</footer>
<script src="https://cdn.jsdelivr.net/gh/google/code-prettify@master/loader/run_prettify.js?skin=sunburst"></script>
</body>
</html>