<table>
<colgroup span="3" style="background:#F9D74E;"></colgroup>
<tr>
<th>Header 1</th>
<th>Header 2</th>
<th>Header 3</th>
<th>Header 4</th>
</tr>
<tr>
<td>Cell</td>
<td>Cell</td>
<td>Cell</td>
<td>Cell</td>
</tr>
<tr>
<td>Cell</td>
<td>Cell</td>
<td>Cell</td>
<td>Cell</td>
</tr>
</table>
The above example uses the span
attribute to span multiple columns within a <colgroup>
element.
You could also have multiple <colgroup>
elements, each with their respective span
values.
<colgroup>
ElementThe <colgroup>
element represents one or more columns within a <table>
element. It can be used to separate columns within a table into logical groups. This can be useful for applying styles across a single column or a group of columns.
<col>
ElementYou can also place <col>
elements inside the <colgroup>
element to specify one or more columns within the colgroup.