HTML <col> Tag

The HTML <col> tag is used for specifying column properties for each column within a <colgroup> element.

The <col> tag can be handy if you need to specify styles across one or more columns. Rather than apply the styles at the individual <td> level, you can apply it to the <col> element. Then all <td> (and <th>) elements contained within that <col> will be styled accordingly.


The <col> tag is written as <col> (no end tag). You can use the span attribute to specify the number of columns to span.

The tag be used within a <colgroup> tag that doesn't have a span attribute.

Like this:


Basic tag usage

Here we apply a different background color to the columns using the <col> tag in conjunction with the CSS background property.



The <col> element accepts the following attributes.

spanSpecifies how many columns to span. This attribute's value must be a valid non-negative integer greater than zero.

Global Attributes

The following attributes are standard across all HTML elements. Therefore, you can use these attributes with the <col> tag , as well as with all other HTML tags.


Event Handlers


Most event handler content attributes can be used on all HTML elements, but some event handlers have specific rules around when they can be used and which elements they are applicable to.

For more detail, see HTML event handler content attributes.