description & Usage
The <col> tag is an abbreviation of the word column, which means column, and is used to add CSS appearance features to table columns.
With this tag, we can select one or more columns as a group and apply the CSS appearance feature to the group.
This tag contains a feature called span, which allows us to select the number of columns in each group.
This tag is used inside the <table> and <colgroup> tags. See the <colgroup> tag page for more information.
For a better understanding, consider the following example:
<table>
<colgroup>
<col style="background-color:blue">
<col span="3" style="background-color:black">
<col style="background-color:pink">
<col span="5" style="background-color:red">
</colgroup>
<table>
In the example above:
In line 3: first column with blue background color (one group with one column)
In line 4: the second, third and fourth columns with black background color (one group with three columns)
In line 5: fifth column with pink background color (one group with one column)
In line 4: 6th, 7th, 8th, 9th and 10th columns with red background color (one group with five columns)
Browser compatibility and Support
# | Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|---|
<col> |
Attributes
Attributes | Values | Description |
---|---|---|
span |
number
|
Determines how many columns should be opened in the corresponding tags on the right. |
Global Attributes
The <col> tag supports the HTML Global Attributes.
Event Attributes
The <col> tag supports the HTML Event Attributes.
Default CSS
Most browsers will display the <col> tag with the following default style: