HTML <col> (Table Column) Tag
Example
<table>
<colgroup>
<col style="background-color:red">
<col span="2" style="background-color:yellow">
</colgroup>
<tr>
<th>No</th>
<th>First Name</th>
<th>Last Name</th>
</tr>
<tr>
<td>01</td>
<td>John</td>
<td>Doe</td>
</tr>
<tr>
<td>02</td>
<td>Michael</td>
<td>Jackson</td>
</tr>
</table>
Meaning
The <col> element defines a column within a table and is used for grouping and alignment purposes.
It parent tag is <colgroup>.
Notes:
- XHTML 1.0 and XHTML5, <col> requires a trailing slash: <col />.
- This element should appear within a <colgroup> element.
Version: HTML 4, 4.01, 5
Standard Syntax
HTML:<col>
XHTML:<col />
Browser Support
Status
Attributes
Attribute | Value | Description |
---|---|---|
span | number | Specifies the number of columns a <col> element should span. (default value is 1) |
Deprecated Attributes
Attribute | Value | Description |
---|---|---|
align | left|center|right|justify | Specifies how horizontal alignment of each column cell content. (Use CSS text-align properties) |
bgcolor | color|hexadecimal | Background color of each column cell content. (Use CSS background-color properties) |
char | character | Specifies the character to which cell contents should align. |
charoff | number | Specifies the number of characters by which the column data should be offset from the alignment characters specified by the char value. |
valign | baseline|bottom|middle|top | Specifies the vertical alignment of the text within each cell of the column. |
width | length | Specifies the width of the text within each cell of the column. |
Global Attributes
The <col> element also supports the Global Attributes in HTML.
Event Attributes
The <col> element also supports the Event Attributes in HTML.
By Default CSS Value(s)
Most of the browsers will display the <> element with the following by default value(s)
col {
display: table-column;
}