hitmill.com
link to hitmill.com home page

 

 

HTML Table Tutorial Lesson 2g
The COLS & COLSPAN Attributes


 

 

COLS

COLS is an attribute of the <TABLE> tag which lets the browser know how many vertical columns are going to be in your table. Some Web authors contend that the browser will render the table faster if you use the COLS attribute. Here is an example:

<TABLE WIDTH="600" COLS="4" BORDER="1" >

The following table has four columns so COLS="4". Forget the fact that those cells in the first row are each spanning two columns and just count the tiny little cells that you can see, such as the ones in the second row. Also, forget the fact that the third row only has one cell -- because it is really spanning or crossing four columns.

LEFTRIGHT
INOUTINOUT
This cell spans 4 columns

 

 

COLSPAN

COLSPAN is an attribute of the <TABLE> tag but is also an attribute of the <TH> and the <TD> tags where I have used it more often than with the <TABLE> tag. COLSPAN tells the browser when you want to have a particular table cell span or cross over more than one column. I have an example here:

LEFTRIGHT
INOUTINOUT
This cell spans 4 columns

 

Getting right down to business you can see examples of the COLSPAN attribute in the table above, in row 1 and row 3. In row 1, each cell is a heading cell (the text is centered) and it spans two columns. It was coded as:

<TR>
<TH COLSPAN="2">LEFT</TH>
<TH COLSPAN="2">RIGHT</TH>
</TR>

The second row of the above table was coded like this:

<TR>
<TD>IN</TD><TD>OUT</TD><TD>IN</TD> <TD>OUT</TD>
</TR>

 

The third row of the above table was coded like this:

<TR>
<TD COLSPAN="4">This cell spans 4 columns</TD>
</TR>

 

 

 
Search Tutorial | Web Services
 
Top | News | Travel | Computers
Internet | HTML | Dynamic HTML | XML
Programming | JavaScript | ASP | Home

 

 
Contact
 
Updated 11 April 2006
© hitmill.com
All Rights Reserved