Skip to: content, navigation

colgroup (HTML element)

Spec
Depr. Empty Version
No No HTML 4
Browser support (more…)
IE5.5+ FF1+ SA1.3+ OP9.2+ CH2+
Full Full Full Full Full

Syntax

<colgroup align=" { center | char | justify | left | right } "span="number" valign=" { baseline | bottom | middle | top } " width=" { number | percentage } ">
</colgroup>

Description

The colgroup is a container for a number of col elements, and allows you to set attributes that you might otherwise set at col level on a number of col elements simultaneously—the attributes defined at this higher level apply to all of the child columns. It is important to note that if you use one or more colgroup then all cols must be enclosed in one or more colgroups

Example

This colgroup element is used to set a class for first three columns (which can then be styled with CSS):

<table border="1">
  <colgroup class="vivid">
    <col/>
    <col/>
    <col/>
  </colgroup>
  <colgroup>
    <col/>
  </colgroup>
  <tr>
    <th colspan="4">Work Contact Points</th>
  </tr>
  ⋮
</table>

Use This For …

This element is used to apply styles (either using HTML attributes or via CSS) to a number of columns simultaneously.

Compatibility

Internet Explorer Firefox Safari Opera Chrome
5.5 6.0 7.0 8.0 1.0 1.5 2.0 3.0 3.5 1.3 2.0 3.1 4.0 9.2 9.5 10.0 2.0
Full Full Full Full Full Full Full Full Full Full Full Full Full Full Full Full Full

This element has reasonable support, though the breadth of support depends heavily on which attributes are applied. Attribute support varies between browsers (it would be so much easier if all browsers tested, supported, and ignored the same set of attributes, but unfortunately, this is not the case).

A better approach is to apply class names to the respective colgroup elements, then let CSS styling take care of alignment, colors, widths, and so on.

In this Section

User-contributed notes

ID:
#2
Contributed:
by sebwin
Date:
Thu, 17 Apr 2008 11:10:41 GMT

To my knowledge, support for this element (and the col element) is virtually non-existant in WebKit (Safari).
And the last time I looked, the most useful attribute, width with values of "*" and "0*", was only properly support in Firefox.
The compatibility table should really be corrected!

Add a note

To post a note on this topic, please log in with your SitePoint username and password. If you don't have an account yet, you can create a new account for free.

Related Products

Search