Home > Abakada: Back to Basics > Language References > HTML Elements > COL Element
Specifies column-based defaults for the table properties. | HTML 4, 4.01, 5 |
HTML Syntax
<col span=columns_count> ...
NOTE: Only the <col
> start tag must be present. The element has no end tag.
The <col
> element enable authors to apply style information to entire columns, instead of repeating styles for each cell in each row.
col does not group columns together structurally ~ that is the role of the <colgroup> element.
col elements are empty and serve only as a support for attributes. They may appear inside or outside an explicit colgroup element.
The col element helps improve faster table rendering. In previous HTML versions, if authors wanted to apply an attribute to an entire column, such as width, span, alignment or style, the attribute had to be coded for each and every cell in the column.
This was not only inefficient as it was cumbersome, but takes longer for browsers to parse cell rendering instructions, and adds to file size as well, especially with larger tables, hence decreasing overall download speed.
The <col>
element supports the following attributes, in addition to global attributes common to all HTML elements.
span | number | Specifies the number of columns a col element should span |
The following example shows how the col element may be used.
<table border width=90% cellpadding=3>
<colgroup>
<col span=2>
<col style="background-color: eed">
</colgroup>
<tbody>
<tr>
<td>This col is in the first group.</td>
<td>This col is in the first group.</td>
<td>This col is in the second group.</td></tr>
</table>
which would render on a Web page as
This col is in the first group. |
This col is in the first group. |
This col is in the second group. |
COLGROUP