COLGROUP - Table Column Group - HTML Help

The Web Design Group

COLGROUP - Table Column Group
Syntax <COLGROUP>...</COLGROUP>
Attribute Specifications
  • SPAN=Number (number of columns in group)
  • WIDTH=MultiLength (width of each column)
  • ALIGN=[ left | center | right | justify | char ] (horizontal alignment of cells in group)
  • CHAR=Character (alignment character for cells)
  • CHAROFF=Length (alignment character offset)
  • VALIGN=[ top | middle | bottom | baseline ] (vertical alignment of cells in group)
  • common attributes
Contents Zero or more COL elements
Contained in TABLE

The COLGROUP element defines a column group in a table. If used, COLGROUP must be after the optional CAPTION and before the optional THEAD in the TABLE. The structural divisions defined by COLGROUP allow authors to easily suggest a presentation for groups of columns through style sheets.

COLGROUP's SPAN attribute defines the number of columns in the group; the default value is 1. A number of other attributes are permitted on COLGROUP, and these are shared among the cells of the group. COLGROUP may contain COL elements that define attributes for the cells of individual columns, overriding attributes defined for the column group. The SPAN attribute should not be used if the COLGROUP contains any COL elements.

The next example features three column groups to structurally divide the table into three parts. The first part is a single column that gives the description of a character. The second part consists of three columns giving different ways of representing the character in HTML. The third part consists of three columns with renderings of the character in the user's browser.

<TABLE SUMMARY="This table gives the character entity reference, decimal character reference, and hexadecimal character reference for 8-bit Latin-1 characters, as well as the rendering of each in your browser."> <COLGROUP> <COLGROUP SPAN=3> <COLGROUP SPAN=3> <THEAD> <TR> <TH SCOPE=col ROWSPAN=2>Character</TH> <TH SCOPE=col ROWSPAN=2>Entity</TH> <TH SCOPE=col ROWSPAN=2>Decimal</TH> <TH SCOPE=col ROWSPAN=2>Hex</TH> <TH SCOPE=colgroup COLSPAN=3>Rendering in Your Browser</TH> </TR> <TR> <TH SCOPE=col>Entity</TH> <TH SCOPE=col>Decimal</TH> <TH SCOPE=col>Hex</TH> </TR> </THEAD> <TBODY> <TR> <TD SCOPE=row>non-breaking space</TD> <TD>&amp;nbsp;</TD> <TD>&amp;#160;</TD> <TD>&amp;#xA0;</TD> <TD>&nbsp;</TD> <TD>&#160;</TD> <TD>&#xA0;</TD> </TR> ... </TBODY> </TABLE>

In place of the <COLGROUP SPAN=3> tag in the preceding example, a COLGROUP with three COL elements could have been used:

<COLGROUP> <COL CLASS=entity> <COL CLASS=decimal> <COL CLASS=hex> </COLGROUP>

Here we have used the CLASS attribute to distinguish the individual columns of the group, allowing us to easily suggest different presentations for the columns through style sheets.

COLGROUP also takes a number of presentational attributes, many of which cannot be completely replaced by style sheets. Since few browsers support COLGROUP, authors may wish to specify these attributes on the TD or TH elements instead.

The WIDTH attribute specifies a width for each column in the group. The value must be a number in pixels, a percentage of the table width, or a relative length expressed as i* where i is an integer. A column with WIDTH="3*" will be allotted three times the width of a column with WIDTH="1*". The value 0* is equivalent to the minimum width necessary for the column's contents.

The ALIGN attribute specifies the horizontal alignment for each cell in the column group. Possible values are left, center, right, justify, and char. ALIGN=char aligns a cell's contents on the character given in the CHAR attribute. The default value for the CHAR attribute is the decimal point of the current language--a period in English. The CHAROFF attribute specifies the offset to the first occurrence of the alignment character. The attribute's value is a number in pixels or a percentage of the cell's width; CHAROFF="50%" centers the alignment character horizontally in a cell.

The VALIGN attribute specifies the vertical position of a cell's contents. Possible values are:

  • top, which positions data at the top of the cell;
  • middle, the default value, which centers the cell data vertically;
  • bottom, which positions data at the bottom of the cell;
  • baseline, which specifies that the first line of each cell in the row with VALIGN=baseline should occur on a common baseline.

More Information

  • COLGROUP in W3C HTML 4.01 Specification
  • COLGROUP in Index DOT Html
Maintained by Liam Quinn <liam@htmlhelp.com>

Web Design Group ~ HTML 4.0 Reference ~ Elements by Function ~ Elements Alphabetically

Từ khóa » Html Colgroup Scope