HTML <col> Tag
- Previous Page <code>
- Next Page <colgroup>
Definition and Usage
<col>
The tag defines attribute values for one or more columns in a table.
To apply styles to all columns<col>
The tag is very useful, so you don't have to apply styles to each cell and each row repeatedly.
Tip
If you want to colgroup Use this element when specifying different attribute values for each column. If there is no col element, the column inherits all attribute values from the colgroup.
The col element is an empty element that only contains attributes. To create a column, you must specify a td element within the tr element.
See also:
HTML Reference Manual:<colgroup> Tag
HTML DOM Reference Manual:Column Object
Example
Use the <colgroup> and <col> tags to set the background color of three columns:
<table> <colgroup> <col span="2" style="background-color:red"> <col style="background-color:yellow"> </colgroup> <tr> <th>ISBN</th> <th>Title</th> <th>Price</th> </tr> <tr> <td>3476896</td> <td>HTML Basics</td> <td>$53</td> </tr> </table>
Attribute
Attribute | Value | Description |
---|---|---|
span | Number | Specifies the number of columns the <col> element should span. |
Global Attributes
<col>
The tag also supports Global Attributes in HTML.
Event Attributes
<col>
The tag also supports Event Attributes in HTML.
Default CSS Settings
Most browsers will use the following default values to display <col>
Element:
col { display: table-column; }
Browser Support
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Support | Support | Support | Support | Support |
- Previous Page <code>
- Next Page <colgroup>