In HTML/XHTML, the <colgroup> and <col> elements allow the vertical columns of a table to be controlled. This is useful for controlling the width of a column of data or other aspects of presentation, such as background color or text color. By using these elements, you can span more than one column or have one column defined for each actual column, as in the following example:
<table>
<colgroup>
<col span=’2’ />
<col />
</colgroup>
<tbody>
<tr>
<td> column 1 </td>
<td> column 2 </td>
<td> column 3 </td>
</tr>
</tbody>
</table>
<col span=’2’ /> controls the presentation of the <td> elements containing the text of column 1 and column 2, the first two columns of the table. The last <col /> element (without the span attribute) controls the presentation of column 3, contained in the last <td> element.
Using CSS, I can continue the example containing my favorite records. This example shows a column defined for each actual column of data, or in other words, each <td> element appearing in a row. In the example a column is defined for each cell, and each row has three cells; consequently, there are three columns. You see what styles are allowed on the <col /> element.