asp.net.ph

Skip Navigation LinksHome > Abakada: Back to Basics > Language References > HTML Elements > COL Element

<col> Element


Specifies column-based defaults for the table properties.HTML 4, 4.01, 5

HTML Syntax

NOTE: Only the <col> start tag must be present. The element has no end tag.

Remarks

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.

Attributes

The <col> element supports the following attributes, in addition to global attributes common to all HTML elements.

AttributeValueDescription
spannumberSpecifies the number of columns a col element should span

Example

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.

External References

See Also

COLGROUP



Check out related books at Amazon

© 2025 Reynald Nuñez and asp.net.ph. All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note