<COL> | NN 6 IE 3 HTML 4 | |||||||||
<COL> | HTML End Tag: Forbidden | |||||||||
The col element provides shortcuts to assigning widths and other characteristics (styles) to one or more subsets of columns within a table or within a table's column group. With this information appearing early in the table element, a browser equipped to do so starts rendering the table before all source code for the table has loaded (the time at which it would otherwise perform all of its geographical calculations). You can use the col element in combination with the colgroup element or by itself. The structure depends on how you need to assign widths and styles to individual columns or contiguous columns. A col element can apply to multiple contiguous columns. By assigning an integer value to the span attribute, you direct the browser to apply the col element's width or style settings to said number of contiguous columns. The span attribute is similar to the colgroup element's colspan attribute. In concert with the colgroup element, the col element allows you to create a kind of subset of related columns within a colgroup set. No matter how you address the column structure of your table, the total number of columns defined in all col and colgroup elements should equal the physical number of columns you intend for the table. The following three skeletal examples specify HTML 4 tables with six columns: <table> <col span="6"> ... </table> <table> <col> <col span="4"> <col> ... </table> <table> <colgroup> <col span="2"></colgroup> <colgroup span="4"> ... </table> HTML 4 specifications for the col element exceed the implementation in IE and Navigator through Version 6. For example, HTML 4 provides for alignment within a column to be around any character, such as the decimal point of a money amount. This kind of feature adds to the rationale behind the col element. For example, you can have a table whose first three columns are formatted one way, and fourth column is assigned a special style with its own alignment characteristics: <html> <head> <style type="text/css"> .colHdrs {color:black} .normColumn {color:green} .priceColumn {color:red} </style> </head> <body> <table> <colgroup class="normColumn" span="3"></colgroup> <col class="priceColumn" align="char" char="."> <thead class="colHdrs"> <tr><th>Stock No.<th>In Stock<th>Description<th>Price</tr> <tbody> <tr><td>8832<td>Yes<td>Brass Frobnitz<td>$255.98</tr> <tr><td>8835<td>No<td>Frobnitz (black)<td>$98</tr> ... </table> </body> </html> Because attributes of the col and colgroup elements apply to the entire column, in the preceding example the style sheet rule for the thead overrides the color settings for the two column styles for the rows enclosed by the thead element. The preceding example works in IE 4 and later for Windows, except for the alignment of the final column, which is ignored. Support indicated here for Netscape 6 is based on the browser's DOM implementation. The DOM reports to scripts that the col element and its attributes exist (reflected as properties). But as of Netscape 7, the element does not perform its intended tasks. A later version will likely connect the element's internal wiring. |
||||||||||
Example | ||||||||||
<COL class="dateCols" width="15" align="right"> |
||||||||||
Object Model Reference | ||||||||||
[window.]document.getElementById(elementID)
|
||||||||||
Element-Specific Attributes | ||||||||||
|
||||||||||
Element-Specific Event Handler Attributes | ||||||||||
None. |
align | NN 6 IE 3 HTML 4 |
align="alignConstant" | Optional |
Establishes the horizontal alignment characteristics of content within column(s) covered by the col element. The HTML 4 specification defines some values for the align attribute that are not yet reflected in the CSS specification. For example, there is no CSS equivalent for the alignment by character. See the col element description about Netscape 6 compatibility. |
|
Example | |
<COL class="dateCols" width="15" align="right"> |
|
Value | |
HTML 4 and IE have two sets of attribute values. The values center, left, and right are self-explanatory (and may be replicated through the CSS text-align attribute). The value justify is intended to space content so that text is justified down both left and right edges. For the value char, the char attribute must also be set to specify the character on which alignment revolves. It is important to bear in mind that the align attribute applies to every row of every column spanned by a col element, including any th element you specify for the table. If you want a different alignment for the column header, override the setting with a separate align attribute or text-align style sheet attribute for the thead or individual th elements. |
|
Default | |
left |
|
Object Model Reference | |
[window.]document.getElementById(elementID).align
|
char | NN 6 IE n/a HTML 4 |
char="character" | Optional |
The char attribute defines the text character used as an alignment point for text within a column. This attribute is of value only for the align attribute set to "char". Microsoft documents a ch attribute, which corresponds to the standards-based char attribute. In any case, the browser does not respond to either attribute. Netscape 7 has not yet connected support for the char attribute. |
|
Example | |
<COL class="priceColumn" align="char" char="."> |
|
Value | |
Any single text character. |
|
Default | |
None. |
charoff | NN 6 IE n/a HTML 4 |
charoff="length" | Optional |
The charoff attribute lets you set a specific offset point at which the character specified by the char attribute is to appear within a cell. This attribute is provided in case the browser default positioning does not meet with the design goals of the table. Microsoft documents a choff attribute, which corresponds to the standards-based charoff attribute. In any case, the browser does not respond to either attribute. Netscape 7 has not yet connected support for the charoff attribute. |
|
Example | |
<COL class="priceColumn" align="char" char="." charoff="80%"> |
|
Value | |
Any length value in pixels or percentage of cell space. |
|
Default | |
None. |
choff | |
See charoff. |
lang | NN 3 IE 4 HTML 4 |
lang="languageCode" | Optional |
The language being used for the element's attribute values and content. A browser can use this information to assist in proper rendering of content with respect to details such as treatment of ligatures (when supported by a particular font or required by a written language), quotation marks, and hyphenation. Other applications and search engines might use this information to aid the selection of spell-checking dictionaries and the creation of indices. |
|
Example | |
<SPAN lang="de">Deutsche Bundesbahn</SPAN> |
|
Value | |
Case-insensitive language code. |
|
Default | |
Browser default. |
|
Object Model Reference | |
[window.]document.getElementById(elementID).lang
|
span | NN 6 IE 3 HTML 4 |
span="columnCount" | Optional |
Defines the number of adjacent columns for which the col element's attribute and style settings apply. If this attribute is missing, the col element governs a single column. You can combine multiple col elements of different span sizes as needed for your column subgrouping. See the col element description about Netscape 6 compatibility. |
|
Example | |
<COL span="3"> |
|
Value | |
Integer value greater than zero. |
|
Default | |
1 |
|
Object Model Reference | |
[window.]document.getElementById(elementID).span
|
valign | NN 6 IE 4 HTML 4 |
valign="alignmentConstant" | Optional |
Determines the vertical alignment of content within cells of the column(s) covered by the col element. You can override the vertical alignment for a particular cell anywhere in the column. See the col element description about Netscape 6 compatibility. |
|
Example | |
<COL valign="middle"> |
|
Value | |
Four constant values are recognized by both IE 4 and later for Windows and HTML 4: top | middle | bottom | baseline. With top and bottom, the content is rendered flush (or very close to it) to the top and bottom of the table cell. Set to middle (the default), the content floats perfectly centered vertically in the cell. When one cell's contents might wrap to multiple lines at common window widths (assuming a variable table width), it is advisable to set the valign attributes of all cells in the same row (or all col elements) to baseline. This assures that the character baseline of the first (or only) line of a cell's text aligns with the other cells in the rowusually the most aesthetically pleasing arrangement. |
|
Default | |
middle |
|
Object Model Reference | |
[window.]document.getElementById(elementID).vAlign
|
width | NN 6 IE 4 HTML 4 |
width="multiLength" | Optional |
Defines the maximum width for the column(s) covered by the col element. In practice (in IE 4 and later for Windows, anyway), the browser won't render a column narrower than the widest contiguous stretch of characters not containing whitespace (e.g., the longest word). The precise measure of such a column width, of course, depends on the font characteristics of the content, as well. See the col element description about Netscape 6 compatibility. |
|
Example | |
<COL width="100"> |
|
Value | |
Internet Explorer accepts length values for the width in the form of pixel measures (without the "px" unit) or percentage of available horizontal space allocated to the entire table (width="25%"). The HTML 4 specification introduces an additional length measurement scheme to supplement the regular length measure. Called a proportional length (also MultiLength), this format features a special notation and geometry. It is best suited for situations in which a col element is to be sized based on the available width of the table space after all fixed length and percentage lengths are calculated. Using the proportional length notation (a number followed by an asterisk), you can direct the browser to divide any remaining space according to proportion. For example, if there is enough horizontal space on the page for 100 pixels after all other column width calculations are performed, three col elements might specify width attributes of 1*, 3*, and 1*. This adds up to a total of five proportional segments. The 100 available pixels are handed out to the proportional columns based on their proportion to the whole of the remaining space: 20, 60, and 20 pixels, respectively. |
|
Default | |
Determined by browser calculation. |