English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
HTML <col> element defines the columns in the table and is used to define the common semantics on all common cells. It is usually located within the <colgroup> element.
The <colgroup> and <col> tags set the background color for three columns in the table:
!doctype html> <html> <head> <meta charset="UTF-8"> <title>Basic Tutorial Website(oldtoolbag.com)</title> </head> <body> <table> <colgroup> <col span="3" style="background-color:#FFF3E0;"> <col style="background-color:orange;"> </colgroup> <thead> <tr> <th>Item</th> <th>Quantity</th> <th>Price</th> <th>Total</th> </tr> </thead> <tbody> <tr> <td>Oranges</td> <td>45</td> <td>$2</td> <td>$90</td> </tr> </tbody> </table> </body> </html>Test to see ‹/›
In this HTML5In the document example, we created a table with <colgroup>, <thead>, and <tbody> sections. In the <colgroup> section, we used two <col> tags. The first <col> tag groups the first three columns and sets the background color of these columns to light orange, that is, #FFF3The hexadecimal value of E0. The second <col> tag groups the fourth column and sets its background color to orange.
IEFirefoxOperaChromeSafari
All mainstream browsers support the <col> tag.
The <col> tag is used for<colgroup>Part, to define the column properties.
By using the <col> tag, you can apply styles to the entire column without having to repeat the styles for each cell or each row.
HTML5 No longer supports HTML 4.01 Most of the attributes.
In HTML, the <col> tag does not have a closing tag.
In XHTML, the <col> tag must be properly closed.
Attribute | Value | Description |
---|---|---|
align | left right center justify char | HTML5 Not supported. Defines the horizontal alignment of the content related to the <col> element. |
char | character | HTML5 Not supported. Defines which character to align the content related to the <col> element by. |
charoff | number | HTML5 Not supported. Defines the offset of the first alignment character. |
span | number | Specifies the number of columns that the <col> element should span. |
valign | top middle bottom baseline | HTML5 Not supported. Defines the vertical alignment of the content related to the <col> element. |
width | % pixels relative_length | HTML5 Not supported. Specifies the width of a <col> element |
Support for <col> tag Global Attributes of HTML.
Support for <col> tag HTML Event Attributes.