Language References
Specifies column-based defaults for the table properties. | HTML 4, 4.01, 5 |
HTML Syntax
<col
align = center | left | right
class = classname
id = value
span = n
style = css properties
title = text
valign = baseline | bottom | middle | top
width = n
>
The COL element allows authors to group together attribute specifications for table columns. The 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 column group ( COLGROUP element ).
The width attribute for COL refers to the width of each column in the element’s span.
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.
COL Members
<table>
<colgroup>
<col align="right">
<col align="left">
<colgroup>
<col align="center">
<tbody>
<tr>
<td>This is the first column in the group and it is right-aligned.</td>
<td>This is the second column in the group and it is left-aligned.</td>
<td>This column is in a new group and it is centered.</td>
</tr>
</table>
This is the first column in the group and it is right-aligned. |
This is the second column in the group and it is left-aligned. |
This column is in a new group and it is centered. |
COLGROUP