Home | Contact Us | Forums   
     
 
 
 
 

Let's tweak our table.

We know how to create a table, but maybe we don't want a table that looks like a grid. We also might want to specify how wide or high a particular cell is.

Maybe you want to create a page layout that has a header, body, and footer. The body has two sections, one for the navigation bar, and one for the body of the page. Lets see what it takes to create that.

<table border=1 width=100>
<tr>
<td colspan=2></td>
</tr>
<tr>
<td></td><td></td>
</tr>
<tr>
<td colspan=2></td>
</tr>
</table>

 
   
 

This code somewhat gives us a page layout that solves our previous problem. The colspan attribute is used within a table data tag to tell it how many cells to span. You must make sure that you keep your table balanced. Do not have more cells in one row than another. Count the colspan number and each additional <td> tag to figure out the number of cells in that row and make sure you keep it consistent. Let's learn a few more attributes.

<table border=1 width=250 cellpadding=1 cellspacing=1>
<tr>
<td colspan=2></td><td width=50></td>
</tr>
<tr height=75>
<td width=50%></td><td width=25%></td><td width=25%></td>
</tr>
<tr>
<td width=75%></td><td colspan=2></td>
</tr>
</table>

   
     
   

See what we can do to shove stuff around. Use these attributes to make your web page hold the layout you desire. Without these attributes the table will try to conform to the data inside and will dynamically change accordingly. If we go to step 3 we can learn how to change colors and backgroungs for the table and cells.

Now lets go to Step 3