table, th, td {
padding: 10px;
border: 1px solid black;
border-collapse: collapse;
}
th.red {
background-color: red;
}
<table>
<thead>
<tr>
<th>q</th><th class="red">w</th><th>e</th><th>r</th><th>t</th><th>y</th>
</tr>
</thead>
<tbody>
<tr>
<td>q1</td><td>w1</td><td>e1</td><td>r1</td><td>t1</td><td>y1</td>
</tr>
<tr>
<td>q2</td><td>w2</td><td>e2</td><td>r2</td><td>t2</td><td>y2</td>
</tr>
</tbody>
</table>
Is there a way to color a table column whose header has a certain class using CSS?
For example, in this table, to color the second column.
2
Answers
You can simulate this by using an overflowing coloration that comes from the header
You can also set a
<colgroup>
…https://developer.mozilla.org/en-US/docs/Web/HTML/Element/col