Table Colgroup
colgroup and col describe columns separately from the row markup. They can apply a limited set of column-level styles without adding a class to every cell.
How it works
- Place a colgroup after caption and before the row groups. Use col elements to describe individual columns or a span of columns.
- Column backgrounds are painted behind cell backgrounds. An opaque background on td or th can hide the column colour.
- Not every CSS property applies meaningfully to columns. Text alignment and padding are normally applied to the cells themselves.
A practical example
<table>
<caption>Workshop places</caption>
<colgroup><col><col class="availability"></colgroup>
<tr><th scope="col">Session</th><th scope="col">Places</th></tr>
<tr><td>Tool care</td><td>6</td></tr>
</table>
Give .availability a background colour in a stylesheet to identify the second column. Keep the heading even when the column has a visual highlight.