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.


Attributes can be added to an HTML element to provide more information about how the element should appear or behave.

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.

For a full explanation of these attributes, see HTML 5 global attributes.

Event Handlers

Event handler content attributes enable you to invoke a script from within your HTML. The script is invoked when a certain "event" occurs. Each event handler content attribute deals with a different event.

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.