A little-known way to style Table Columns in CSS
The primary (only) grouping for table cell data in HTML are rows, not
columns, much to the consternation of spreadsheet users. But! HTML also
contains a seldom-seen <col>
marker element, to be inserted at the
beginning of the table, once per desired column. It doesn’t wrap <td>
content, the way that <tr>
does — it’s just a weird, forlorn magical
orphan that then lets you select vertical regions of your table.
Selecting vertical table regions with <col>
markers
<table>
<!-- strange, non-semantic column markers-->
<col>
<col>
<!-- table row -->
<tr>
<td>1</td>
<td>2</td>
</tr>
</table>
Click “HTML” or “SCSS” below to view this in action
Why would you do this? I don’t exactly know. I think it’s an older holdover from a table-based world. The current prevalent way of doing this is selecting td:nth-child(2)