Name

<COLGROUP> — NN n/a IE 3 HTML 4

Synopsis

<COLGROUP>...</COLGROUP>

End Tag: Optional

The COLGROUP element provides shortcuts to assigning widths and other characteristics (styles) to one or more subsets of columns within a table. With this information appearing early in the TABLE element source code, a browser equipped to do so starts rendering the table before all source code for the table has loaded (at which time it would otherwise perform all of its geographical calculations).

You can use the COLGROUP element in combination with the COL element or by itself. You may also define a COLGROUP that has COL elements nested within to assist in defining subsets of columns that share some attribute or style settings. The need for the element’s end tag is determined by the presence of standalone COL elements following the COLGROUP element. For example, if you specify column groupings entirely with COLGROUP elements, end tags are not necessary:

<TABLE>
<COLGROUP SPAN=2 WIDTH=30>
<COLGROUP SPAN=3 WIDTH=40>
<THEAD>

If you have a freestanding COL element following the COLGROUP element, you must clearly end the COLGROUP element before the standalone COL element:

<TABLE>
<COLGROUP CLASS="leftCols">
<COL WIDTH=30>
<COL WIDTH=20>
</COLGROUP>
<COL CLASS="priceCol" WIDTH=25>
<THEAD>
...

The structure depends on how you need to assign widths and styles to individual columns or contiguous columns. To create a column grouping that consists of multiple adjacent columns, use the SPAN attribute. This ...

Get Dynamic HTML: The Definitive Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.