Paul D. Waite Paul D. Waite - 2 months ago 10
HTML Question

What’s the correct scope value to use for an HTML <th> table cell than spans several columns?

Say you’ve got an HTML table, with a

<th>
cell that spans several columns, e.g.

<table>
<tr>
<th colspan="3" scope="?">Scores</th>
<!-- ...more headings here... -->
</tr>
<tr>
<th scope="col">English</th>
<th scope="col">Maths</th>
<th scope="col">Science</th>
<!-- ...more sub-headings here... -->
</tr>
<tr>
<td>12</td>
<td>16</td>
<td>20</td>
<!-- ...more cells here... -->
</tr>
</table>


What’s the correct value for the scope attribute for the spanning header cell?
col
seems incorrect as it’s heading several columns, but
colgroup
does’t seem right if I don’t actually have any
colgroup
tags.

Answer

According to the second example table in the HTML spec, it’s colgroup, despite the lack of colgroup tags.

http://www.w3.org/TR/html4/struct/tables.html#h-11.4.1