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

Browser Compatibility  

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support 1.0 1.0 (1.7 or earlier) (Yes) (Yes) (Yes)
align/valign attribute ? Not supported bug 915 ? ? ?
char/charoff attribute ? Not supported bug 2212 ? ? ?
bgcolor attribute ? Not supported (Yes) ? ?
Feature Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support ? 1.0 (1.0) ? ? ?
align/valign attribute ? Not supported bug 915 ? ? ?
char/charoff attribute ? Not supported bug 2212 ? ? ?
bgcolor attribute ? Not supported ? ? ?

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 '.'.

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

Element HTML HTML tabular data Reference Tables Web