HTML <col> tag

Updated: 11/13/2018 by Computer Hope
HTML col tag

When writing in HTML, the <col> tag is used to designate certain properties for each column contained in a <colgroup> element. It is useful when you want to apply formatting to an entire column, rather than each cell individually. The following sections contain information about the <col> tag, including an example of it in use, as well as related attributes and browser compatibility.

Example of <col> code

<table class="mtable2 tab">
<colgroup>
<col span="1" style="background-color:#c1c1c3">
<col style="background-color:white">
</colgroup>
<tr>
<th>Month</th>
<th>Savings</th>
</tr>
<tr>
<td>March</td>
<td>$200</td>
</tr>
<tr>
<td>April</td>
<td>$300</td>
</tr>
<tr>
<td>May</td>
<td>$250</td>
</tr>
</table>

Example result

Month Savings
March $200
April $300
May $250

As the HTML code indicates, the entire table has a background color of white and the first column is "painted" grey. The table itself has one of our CSS classes applied to it to improve its appearance.

Deprecated attributes

Within an HTML tag, an attribute dictates certain aspects of an HTML element. Attributes are made up of a name and value pair; all tags support standard attributes. The following table shows all of the deprecated unique HTML attributes for the <col> tag, as well as a description of each. While these attributes may work with the some versions of HTML, they will eventually be phased out. You should use CSS to adjust the dimensions of this element.

Attribute Description
align Designates the alignment of content inside an element.
char Designates the character within a column to align with the rest of the content.
charoff Designates the number of characters to offset the column's content by relative to the char attribute.
span Designates the number of columns the <col> element should cover.
valign Designates the vertical alignment of content with the <col> element.
width Designates how wide the <col> element should be.

Compatibility

Edge Internet Explorer Firefox Safari Opera Chrome
All versions All versions All versions All version All versions All versions

Browser, Cell, Class, Compatibility, Format, Row, Table, Web design terms