W3 3.2n
4.0y
NS 3.0n
4.0n
IE 3.0y
4.0y
TV 1.2n
2.1n

<COL>

Description

This element sets the attribute values for one or more columns. This element is only valid inside a COLGROUP. You use this element when you want to specify different attribute values to a column inside a column group created with the COLGROUP element.
Without COL element a column will inherit all its attribute values from the column group where it is in.

DTD

<!ELEMENT COL      - O EMPTY           -- table column -->
<!ATTLIST COL                          -- column groups and properties --
  %attrs;                              -- %coreattrs, %i18n, %events --
  span        NUMBER         1         -- COL attributes affect N columns --
  width       %MultiLength;  #IMPLIED  -- column width specification --
  %cellhalign;                         -- horizontal alignment in cells --
  %cellvalign;                         -- vertical alignment in cells --
  >
from the HTML 4.0 DTD, "Copyright © W3C, (MIT, INRIA, Keio). All Rights Reserved."

Attributes

Core attributes: class id style title
Internationalization attributes: dir lang
Events: onclick ondblclick onmousedown onmouseup onmouseover onmousemove onmouseout onkeypress onkeydown onkeyup

W3 3.2n
4.0y
NS 3.0n
4.0n
IE 3.0y
4.0y
TV 1.2n
2.1n
ALIGN
Set the horizontal alignment of the contents of the table cells in the column. These values overrule previous settings that were set with the COLGROUP element. Possible values are :

Value Description
center The contents of table cells are centered.
This is the default value for table headers, defined with the TH element.
char This attribute defines that the contents of table cells must be centered around a certain character. Which character this is, is defined with the char attribute.

If no char attribute is given, a default character is used. This is the character that is defined to represent the decimal point in the current language. In English this is the period ("."), in Dutch it is the comma (",").

justify The contents of table cells is evenly spread between the left and right border of a table cell. This is achieved by enlarging the space between each word on a line.
left The contents of table cells are aligned to the left side.
This is the default value for table data cells defined with the TD element.
right The contents of table cells are aligned to the right side.

align="char" is not supported by IE 4.0.


W3 3.2n
4.0y
NS 3.0n
4.0n
IE 3.0n
4.0n
TV 1.2n
2.1n
CHAR
When you specify align="char", this attribute specifies which character must be used to center the text around.

When more than one occurrence of the character is present, the first occurrence is used.


W3 3.2n
4.0y
NS 3.0n
4.0n
IE 3.0n
4.0n
TV 1.2n
2.1n
CHAROFF
This attribute specifies an offset that must be used when align="char" is used. The value can be specified as a number of pixels, or as a percentage of the current width.

This offset is added to the position where the character to center around is. The direction of the offset depends on the current direction of the text.

When the alignment character isn't present in the line, the text is shifted, so that the text ends at the offset.


W3 3.2n
4.0y
NS 3.0n
4.0n
IE 3.0y
4.0y
TV 1.2n
2.1n
SPAN
This attribute defines the number of columns that are affected by the attribute values set in this element. The default value is 1.
W3 3.2n
4.0y
NS 3.0n
4.0n
IE 3.0n
4.0y
TV 1.2n
2.1n
VALIGN
Set the vertical alignment of the contents of the table cells in the column. These values overrule previous settings that were set with the COLGROUP element. Possible values are :

Value Description
baseline The first line of the contents of the cell are aligned with a common baseline.
bottom The text in each cell in the column is aligned at the bottom of the cell.
middle The text is centered vertically in each cell in the column.
top The text in each cell in the column is aligned at the top of the cell.


W3 3.2n
4.0y
NS 3.0n
4.0n
IE 3.0n
4.0y
TV 1.2n
2.1n
WIDTH
This attribute sets the width of each column spanned, and overrides any width set in the COLGROUP to which the column belongs.

The value can be specified as a number of pixels, a percentage of the current width, or as a relative length.

A relative length is a number followed by a "*". The way this works is that the available space is spread over the specified values, where the number defines the relative proportion to the other columns.

For example: A table of 250 pixels wide consists of three columns, the first with width="1*", the second with width="3*", and the third with width="1*".
The available width is divided by 5 (1 + 3 + 1) = 50 and each column gets a portion according to its value, resulting in column widths of 50, 150 and 50 pixels. (See the first example).

Relative widths are not supported by IE 4.0.

Examples

Source
<TABLE border width="400">
<COLGROUP>
<COL width="1*">
<COL width="2*">
<COL width="1*">
</COLGROUP>
<TR>
<TD>The first column</TD>
<TD>The second column</TD>
<TD>The third column</TD>
</TR>
</TABLE>
 
Result
The first column The second column The third column
 
Source
<TABLE border width="100%">
<COLGROUP>
<COL span="2" align="right">
<COL align="center">
<TR>
<TD>This column is<BR>right-aligned.</TD>
<TD>This column is also right-aligned.</TD>
<TD>This column is centered.
<P>
<IMG src="IMG1.jpg" alt="A nice bird" width="56" height="100">
</TD>
</TR>
</TABLE>
 
Result
This column is
right-aligned.
This column is also right-aligned. This column is centered.

A nice bird

Statistics