col

FilterElements

HTML: <col>
XHTML: <col/>  or  <col />

Establishes a column (or columns via the span attribute) within a table so that attribute properties may be applied to all the cells in the column(s). The col element does not group columns structurally (that is handled by the colgroup element) but rather is an empty element that allows attributes to be shared. The col element must appear after the caption element and before any row (tr) or row group (thead, tbody, tfoot) elements with the table element.

Start/End Tags

This is an empty element. In HTML, the end tag is forbidden. In XHTML, the element must be closed with a trailing slash as just shown. Developers may include a space character before the slash for backward compatibility with older browsers.

Specifications

  • HTML 4.01
  • HTML5

align=

Values: left | right | center | justify | char
Not in HTML5. Specifies the horizontal alignment of text in a cell or cells. The default value is left.

char=

Values: character
Not in HTML5. Specifies a character along which the cell contents will be aligned when align is set to char. The default character is a decimal point (language-appropriate). This attribute is generally not supported by current browsers.

charoff=

Values: length
Not in HTML5. Specifies the offset distance to the first alignment character on each line. If a line doesn’t use an alignment character, it should be horizontally shifted to end at the alignment position. This attribute is generally not supported by current browsers.

span=

Values: number
Specifies the number of columns "spanned" by the col element. The default value is 1. All columns indicated in the span are formatted according to the attribute settings in col.

valign=

Values: top | middle | bottom | baseline
Not in HTML5. Specifies the vertical alignment of text in the cells of a column.

width=

Values: pixels, percentage, n*
Not in HTML5. Specifies the width of each column spanned by the col element. Width can be measured in pixels or percentages, or defined as a relative size (*). For example, 2* sets the column two times wider than the other columns; 0* sets the column width at the minimum necessary to hold the column’s contents. The width attribute in the col element overrides the width settings of the containing colgroup element.

See also colgroup and table

HTML
<table>
<col span="2" width="100" class="name">
<col span="1" width="50" class="date">
<thead> ... (markup continues)
XHTML
<table>
<col span="2" width="100" class="name" />
<col span="1" width="50" class="date" />
<thead> ... (markup continues)

Rendered Example

col is used to organize table cells into conceptual column units. It does not affect rendering.