<col>
The <col>
element in HTML is used to define properties for table columns, such as styling or attributes, and is often used within a <colgroup>
to apply these properties to multiple columns simultaneously.
Syntax
<col attributes>
HTML tables are defined by their rows, not by columns. The result of this is that any style applied to a row will override any style applied to the column. attributes
are a handful of CSS properties that can be controlled via the <col>
element, such as:
- border
- background
- width
- visibility
Example
This example provides a schedule table for a Poetry Workshop. In this table, the <col>
element is utilized to set the background color of the columns. This illustrative instance also demonstrates that when a style is applied to a row, it takes precedence over any style applied to a column. The span
attribute is set to 2 because the style applied to the first column is overridden by the row’s style.
<colgroup><col span="2" style="background-color:#EBC7B9;" /><col style="background-color:#EBD0B9" /><col style="background-color:#EBDEB9" /></colgroup>
All contributors
- Anonymous contributorAnonymous contributor14 total contributions
- Anonymous contributor
Looking to contribute?
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.