Anonymous contributor's avatar
Anonymous contributor
Anonymous contributor's avatar
Anonymous contributor
Published Nov 24, 2023
Contribute to Docs

The <col> element in HTML is used to define properties for table columns, such as styling or attributes, and is often used within a <colgroup> to apply these properties to multiple columns simultaneously.


<col attributes>

HTML tables are defined by their rows, not by columns. The result of this is that any style applied to a row will override any style applied to the column. attributes are a handful of CSS properties that can be controlled via the <col> element, such as:

  • border
  • background
  • width
  • visibility


This example provides a schedule table for a Poetry Workshop. In this table, the <col> element is utilized to set the background color of the columns. This illustrative instance also demonstrates that when a style is applied to a row, it takes precedence over any style applied to a column. The span attribute is set to 2 because the style applied to the first column is overridden by the row’s style.

<col span="2" style="background-color:#EBC7B9;" />
<col style="background-color:#EBD0B9" />
<col style="background-color:#EBDEB9" />

Rendered col tag

All contributors

Looking to contribute?

Learn HTML on Codecademy