<colgroup>: The "column group" element of a table

The HTML <colgroup> element defines a group of columns within a table.

Attributes

span

This attribute contains a positive integer indicating the number of consecutive columns that the <colgroup> element spans. If it is not present, its default value is 1.

The span attribute is not allowed if there is one or more <col> elements within the <colgroup>.

Deprecated attributes

The following attributes are deprecated and should not be used. They are documented below for your reference when updating existing code and for historical interest only.

align

This enumerated attribute specifies how the horizontal alignment of the contents of each column cell will be handled. Possible values are:

  • left, to align the cell contents to the left

  • center, to center the contents of the cell

  • right, to align the cell contents to the right

  • justify, to insert spaces in the textual content so that the content is justified within the cell

If this attribute is not set, its align value is inherited from the <colgroup> element to which this <col> element also belongs. If there are none, the value left is assumed.

bgcolor

The background color of the table. It is a 6-digit hexadecimal RGB code, preceded by a '#'. You can also use one of the predefined color keywords.

To achieve a similar effect, use the CSS background-color property.

char

This attribute is used to set the character to align cells in a column. Typical values for this include a period (.) when trying to align numbers or monetary values. If align is not set to char, this attribute is ignored.

charoff

This attribute is used to indicate the number of characters to offset the column data from the alignment characters specified by the attribute

valign

This attribute specifies the vertical alignment of the text within each cell of the column. Possible values for this attribute are:

  • baseline, which will put the text as close to the bottom of the cell as possible, but will align it to the baseline of the characters rather than the bottom of them. If the characters are all the size, this has the same effect as bottom.
  • bottom, which will put the text as close to the bottom of the cell as possible;
  • middle, which centers the text in the cell;
  • and top, which will put the text as close to the top of the cell as possible.

Examples

See the <table> page for examples on <colgroup>.