colgroup

FilterElements

<colgroup> ... </colgroup>

Defines a conceptual group of columns that form a structural division within a table. The colgroup element must appear after the caption element and before any row (tr) or row group (thead, tbody, tfoot) elements with the table element.

A table may include more than one column group. The number of columns in a group is specified either by the value of the span attribute or by a tally of column (col) elements within the group. Column groups may be useful in speeding table display (for example, the columns can be displayed incrementally without waiting for the entire contents of the table) and provide a system for display on nonvisual display agents such as speech- and Braille-based browsers.

Start/End Tags

HTML 4.01: Required/Optional; HTML5: Optional/Optional; XHTML: Required/Required

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 table

<table> <colgroup id="employinfo">
  <col span="2" width="100">
  <col span="1" width="50" class="date">
</colgroup>
<thead> . . . (markup continues)

Rendered Example

colgroup organizes conceptual columns into groups.