Learn HTML Code Tutorial Reference Guide

<COL ...>

  • SPAN: how many columns this affects
  • ALIGN: horizontal alignment
 
  • WIDTH: width of the column
  • BGCOLOR: background color of the column

<COL ...> sets properties for a column of table cells. <COL ...> is an HTML 4.0 tag. Currently only MSIE and Netscape 6 recognize it.

<COL ...> goes after the <TABLE ...> tag and before any <TR ...>, <THEAD ...>, or <TBODY ...> elements. (It may go inside a <COLGROUP ...> element but it doesn't have to.) Each <COL ...> defines the properties of one column, unless you use SPAN to indicate that it is for more than one column. So the first <COL ...> sets the properties for the first column, the second <COL ...> sets the properties for the second column, and so on.

For example, the following code uses three <COL ...> tags to set properties of the cells in the first, second, and third columns of the table. The first <COL ...> doesn't do anything except serve a placeholder for the first column. The second <COL ...> uses the ALIGN attribute to right align all the cells in the second column. The third <COL ...> uses STYLE to set the styles of the cells in the third column so that the font color is red:

<TABLE BORDER CELLPADDING=5>

<COL>
<COL ALIGN=RIGHT>
<COL STYLE="color:red">

<TR> <TH>Expense</TH> <TH>Price</TH> <TH>Status</TH> </TR>
<TR> <TD>office suite</TD> <TD>1,343.56</TD> <TD>rental</TD> </TR>
<TR> <TD>cabling</TD> <TD>1.25</TD> <TD>installed</TD> </TR>
</TABLE>

which gives us this table:

Expense Price Status
office suite 1,343.56 rental
cabling 1.25 installed

It's important to be absolutely clear on this point: <COL ...> does not create columns. It merely sets the properties of columns that will be defined later in the code. Cells are not "contained" in <COL ...> elements, they just set attributes which are applied to the cells in that column position.




 

Home
  |   Tutorials   |   Forum   |   Quick List   |   Link Directory   |   Privacy Policy   |   About
Copyright ©1997-2002 Idocs and ©2002-2014 HTML Code Tutorial