You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jul 11, 2024. It is now read-only.
Rearrange table examples to include the irregular tables example one as
example two on the page about simple tables.
Also add scope to the delivery slots example.
Change intro text.
Copy file name to clipboardExpand all lines: source/tables/simple.html.erb.md
+96-22Lines changed: 96 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,11 +9,13 @@ wcag_techniques:
9
9
10
10
A simple table has one header row, or a header row and header column. They are the first row and column of the table.
11
11
12
-
Use header cell elements (`<th>`) to markup the header cells so that they are distinguishable from data cells and associated with the correct data cells. For example, in the [second table below](#table-with-header-cells-in-the-top-row-and-first-column) “Closed” is meaningless on its own, but makes sense when it’s associated with time (the row header) and day (the column header).
12
+
Use header cell elements (`<th>`) to markup the header cells so that they are distinguishable from data cells and associated with the correct data cells. For example, in the [third example below](#table-with-header-cells-in-the-top-row-and-first-column) “Closed” is meaningless on its own, but makes sense when it’s associated with time (the row header) and day (the column header).
13
13
14
-
Additionally, you can use the [`<caption> element`](caption-summary.html) to identify the table, which in some cases might be a WCAG 2.0 requirement.
14
+
To explicitly associate header cells to data cells, it is usually useful to use the `scope` attribute. If the `scope` value is `row`, the heading is only a heading for other cells in this row, if the value is `col` it is the heading only for other cells in this column.
15
15
16
-
If the table has only a header column, see the [first example of the Irregular Tables tutorial](irregular.html#table-with-header-cells-in-one-column-only).
16
+
For more complex examples on the use of `scope`, see the [Irregular Tables tutorial](irregular.html).
17
+
18
+
Additionally, you can use the [`<caption>` element](caption-summary.html) to identify the table, which in some cases might be a WCAG 2.0 requirement.
17
19
18
20
## Table with header cells in the top row only
19
21
{:.ex}
@@ -76,49 +78,121 @@ This table of concerts only needs the cells in the top row marked up as `<th>` c
76
78
77
79
[Full code for “Table with header cells in the top row only”](examples/headertoprow.html)
78
80
81
+
## Table with header cells in one column only
82
+
{:.ex}
83
+
84
+
This example has `<th>` elements for all cells in the left column of a table. As the heading cells are read in every line, the `scope` attribute with a value of `row` should be used on each `<th>` cell to ensure that it cannot be mistaken as a header for other cells in the same column. In the table below, Belgium should not be mistaken as the heading for France, Holland, etc.
85
+
86
+
{::nomarkdown}
87
+
<%= sample_start %>
88
+
89
+
<table>
90
+
<caption>
91
+
Capital cities
92
+
</caption>
93
+
<tr>
94
+
<th scope="row">Belgium</th>
95
+
<td>Brussels</td>
96
+
</tr>
97
+
<tr>
98
+
<th scope="row">France</th>
99
+
<td>Paris</td>
100
+
</tr>
101
+
<tr>
102
+
<th scope="row">Holland</th>
103
+
<td>Amsterdam</td>
104
+
</tr>
105
+
<tr>
106
+
<th scope="row">Luxembourg</th>
107
+
<td>Luxembourg</td>
108
+
</tr>
109
+
<tr>
110
+
<th scope="row">Spain</th>
111
+
<td>Madrid</td>
112
+
</tr>
113
+
<tr>
114
+
<th scope="row">UK</th>
115
+
<td>London</td>
116
+
</tr>
117
+
</table>
118
+
119
+
<%= sample_end %>
120
+
{:/nomarkdown}
121
+
122
+
{::nomarkdown}
123
+
<%= code_start %>
124
+
{:/nomarkdown}
125
+
126
+
~~~html
127
+
<table>
128
+
<caption>Capital cities</caption>
129
+
<tr>
130
+
<thscope="row">Belgium</th>
131
+
<td>Brussels</td>
132
+
</tr>
133
+
<tr>
134
+
<thscope="row">France</th>
135
+
<td>Paris</td>
136
+
</tr>
137
+
<tr>
138
+
<thscope="row">Holland</th>
139
+
<td>Amsterdam</td>
140
+
</tr>
141
+
[…]
142
+
</table>
143
+
~~~
144
+
145
+
{::nomarkdown}
146
+
<%= code_end %>
147
+
{:/nomarkdown}
148
+
149
+
[Full code Example “Table with header cells in one column only”](examples/scope-simple.html)
150
+
79
151
## Table with header cells in the top row and first column
80
152
{:.ex}
81
153
82
-
This table of opening times has header information contained in both the top row and the first column. All header cells are marked up as `<th>` cells.
154
+
This table of opening times has header information contained in both the top row and the first column. All header cells are marked up as `<th>` cells, additionally we add `scope` attributes with the values `col` (to the top row header cells) and `row` (to the first column header cells).
83
155
84
156
{::nomarkdown}
85
157
<%= sample_start %>
86
158
159
+
<p><strong>Delivery slots:</strong></p>
160
+
87
161
<table>
88
162
<tr>
89
-
<th>Delivery slots</th>
90
-
<th>Monday</th>
91
-
<th>Tuesday</th>
92
-
<th>Wednesday</th>
93
-
<th>Thursday</th>
94
-
<th>Friday</th>
163
+
<td></td>
164
+
<th scope="col">Monday</th>
165
+
<th scope="col">Tuesday</th>
166
+
<th scope="col">Wednesday</th>
167
+
<th scope="col">Thursday</th>
168
+
<th scope="col">Friday</th>
95
169
</tr>
96
170
<tr>
97
-
<th>09:00 - 11:00</th>
171
+
<th scope="row">09:00 - 11:00</th>
98
172
<td>Closed</td>
99
173
<td>Open</td>
100
174
<td>Open</td>
101
175
<td>Closed</td>
102
176
<td>Closed</td>
103
177
</tr>
104
178
<tr>
105
-
<th>11:00 - 13:00</th>
179
+
<th scope="row">11:00 - 13:00</th>
106
180
<td>Open</td>
107
181
<td>Open</td>
108
182
<td>Closed</td>
109
183
<td>Closed</td>
110
184
<td>Closed</td>
111
185
</tr>
112
186
<tr>
113
-
<th>13:00 - 15:00</th>
187
+
<th scope="row">13:00 - 15:00</th>
114
188
<td>Open</td>
115
189
<td>Open</td>
116
190
<td>Open</td>
117
191
<td>Closed</td>
118
192
<td>Closed</td>
119
193
</tr>
120
194
<tr>
121
-
<th>15:00 - 17:00</th>
195
+
<th scope="row">15:00 - 17:00</th>
122
196
<td>Closed</td>
123
197
<td>Closed</td>
124
198
<td>Closed</td>
@@ -137,23 +211,23 @@ This table of opening times has header information contained in both the top row
0 commit comments