HTML - <col>
The HTML Table Column Element (<col>) defines a column within a table and is used for defining common semantics on all common cells. It is generally found within a <colgroup>
element.
Example
Please see the <table>
page for examples on <col>
.
Description
The HTML Table Column Element (<col>) defines a column within a table and is used for defining common semantics on all common cells. It is generally found within a <colgroup>
element.
This element allows styling columns using CSS, but only a few attributes will have an effect on the column (see the CSS 2.1 specification for a list).
Content categories | None. |
---|---|
Permitted content | None, it is an empty element. |
Tag omission | The start tag is mandatory, but, as it is a void element, the use of an end tag is forbidden. |
Permitted parent elements | <colgroup> only, though it can be implicitly defined as its start tag is not mandatory. The <colgroup> must not have a span attribute. |
DOM interface | HTMLTableColElement |
Attributes
Includes the Global Attributes.
Name | Version | Description | ||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
align |
This enumerated attribute specifies how horizontal alignment of each column cell content will be handled. Possible values are:
If this attribute is not set, its value is inherited from the Note: Do not use this attribute as it is obsolete (not supported) in the latest standard.
|
|||||||||||||||||||||||||||||||||
bgcolor |
This attribute defines the background color of each cell of the column. It is one of the 6-digit hexadecimal code as defined in sRGB, prefixed by a '#'. One of the sixteen predefined color strings may be used:
Usage note: Do not use this attribute, as it is non-standard and only implemented in some versions of Microsoft Internet Explorer: the
<col> element should be styled using CSS. To give a similar effect to the bgcolor attribute, use the CSS property background-color , on the relevant <td> elements. |
|||||||||||||||||||||||||||||||||
char |
This attribute is used to set the character to align the cells in a column on. Typical values for this include a period (.) when attempting to align numbers or monetary values. If align is not set to char , this attribute is ignored.
Note: Do not use this attribute as it is obsolete (and not supported) in the latest standard. To achieve the same effect as the
char , in CSS3, you can use the character set using the char attribute as the value of the text-align property Unimplemented. |
|||||||||||||||||||||||||||||||||
charoff |
This attribute is used to indicate the number of characters to offset the column data from the alignment characters specified by the char attribute.
Note: Do not use this attribute as it is obsolete (and not supported) in the latest standard.
|
|||||||||||||||||||||||||||||||||
span |
This attribute contains a positive integer indicating the number of consecutive columns the <col> element spans. If not present, its default value is 1 . |
|||||||||||||||||||||||||||||||||
valign |
This attribute specifies the vertical alignment of the text within each cell of the column. Possible values for this attribute are:
Note: Do not use this attribute as it is obsolete (and not supported) in the latest standard:
|
|||||||||||||||||||||||||||||||||
width |
This attribute specifies a default width for each column in the current column group. In addition to the standard pixel and percentage values, this attribute might take the special form 0* , which means that the width of each column in the group should be the minimum width necessary to hold the column's contents. Relative widths such as 0.5* also can be used. |
Browser Compatibility
See Also
- Other table-related HTML elements:
<caption>
,<colgroup>
,<table>
,<tbody>
,<td>
,<tfoot>
,<th>
,<thead>
,<tr>
; - CSS properties and pseudo-classes that may be specially useful to style the
<col>
element:- the
width
property to control the width of the column; - the
:nth-child
pseudo-class to set the alignment on the cells of the column; - the
text-align
property to align all cells content on the same character, like '.'.
- the
Specifications
Specification | Status | Comment |
---|---|---|
WHATWG HTML Living Standard The definition of '<col>' in that specification. |
Living Standard | |
HTML5 The definition of '<col>' in that specification. |
Recommendation | |
HTML 4.01 Specification The definition of '<col>' in that specification. |
Recommendation | Initial definition |
License
© 2016 Mozilla Contributors
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-us/docs/web/html/element/col