Learn to Build a Website

Table Tutor

Lesson 3

Let's go back to plain old Geetham.

<TABLE BORDER=3 WIDTH=100 HEIGHT=75>
<TR>
<TD ALIGN=LEFT VALIGN=MIDDLE>Geetham</TD>
</TR>
</TABLE>

 
Geetham


And for the sake of clarity and simplicity let's remove the alignment attributes. We know what will happen because we know what the default values are. By the way, a TAG tells the browser to do something. An ATTRIBUTE goes inside the TAG and tells the browser how to do it.

<TABLE BORDER=3 WIDTH=100 HEIGHT=75>
<TR>
<TD>Geetham</TD>
</TR>
</TABLE>

 
Geetham


Now we will make our table a fuzz bigger.

<TABLE BORDER=3 WIDTH=300 HEIGHT=75>
<TR>
<TD>Geetham</TD>
</TR>
</TABLE>

 
Geetham
You should know that fuzz is a technical term. Its full definition is so broad and complicated that it would only be suitable for advanced html students.


Sultan is back and this time he wants his own cell.

<TABLE BORDER=3 WIDTH=300 HEIGHT=75>
<TR>
<TD>Geetham</TD>
<TD>Sultan</TD>
</TR>
</TABLE>

 
Geetham Sultan


When no instructions are given to the browser, each cell may (but not always) be different in size. It's always a fine idea to specify how big each cell is. Make sure your arithmetic is correct or what people see may be drastically different than what you want them to see!

<TABLE BORDER=3 WIDTH=300 HEIGHT=75>
<TR>
<TD WIDTH=150>Geetham</TD>
<TD WIDTH=150>Sultan</TD>
</TR>
</TABLE>

 
Geetham Sultan


These WIDTH attributes can also be expressed as a percentage.

<TABLE BORDER=3 WIDTH=300 HEIGHT=75>
<TR>
<TD WIDTH=50%>Geetham</TD>
<TD WIDTH=50%>Sultan</TD>
</TR>
</TABLE>

 
Geetham Sultan


Lets give Geetham a bigger cell since it's been here from the beginning.

<TABLE BORDER=3 WIDTH=300 HEIGHT=75>
<TR>
<TD WIDTH=80%>Geetham</TD>
<TD WIDTH=20%>Sultan</TD>
</TR>
</TABLE>

 
Geetham Sultan


Now Ibrahim is back and of course he wants his own cell. We need to decide how much of the row we will give him. I suppose 20% is fair. Make sure to adjust Geetham's share also.

<TABLE BORDER=3 WIDTH=300 HEIGHT=75>
<TR>
<TD WIDTH=60%>Geetham</TD>
<TD WIDTH=20%>Sultan</TD>
<TD WIDTH=20%>Ibrahim</TD>
</TR>
</TABLE>

 
Geetham Sultan Ibrahim


Three other geetham members see what's going on and they want to be in your table. I think we will give them their own row.

<TABLE BORDER=3 WIDTH=300 HEIGHT=75>

<TR>
<TD WIDTH=60%>Geetham</TD>
<TD WIDTH=20%>Sultan</TD>
<TD WIDTH=20%>Ibrahim</TD>
</TR>

<TR>
<TD>Kassim</TD>
<TD>Naseer</TD>
<TD>Purusoth</TD>
</TR>

</TABLE>

 
Geetham Sultan Ibrahim
Kassim Naseer Purusoth
The WIDTH attributes in the first row carry over to the second row.


If Purusoth leaves, we still have a perfectly good table, it just has an empty spot.

<TABLE BORDER=3 WIDTH=300 HEIGHT=75>

<TR>
<TD WIDTH=60%>Geetham</TD>
<TD WIDTH=20%>Sultan</TD>
<TD WIDTH=20%>Ibrahim</TD>
</TR>

<TR>
<TD>Kassim</TD>
<TD>Naseer</TD>
</TR>

</TABLE>

 
Geetham Sultan Ibrahim
Kassim Naseer


Let's put Purusoth back and remove all attributes except BORDER.

<TABLE BORDER=3>

<TR>
<TD>Geetham</TD>
<TD>Sultan</TD>
<TD>Ibrahim</TD>
</TR>

<TR>
<TD>Kassim</TD>
<TD>Naseer</TD>
<TD>Purusoth</TD>
</TR>

</TABLE>

 
Geetham Sultan Ibrahim
Kassim Naseer Purusoth


Next are a couple of attributes called CELLPADDING and CELLSPACING. Both are used up front in the <TABLE> tag. CELLPADDING is the amount of space between the border of the cell and the contents of the cell.

<TABLE BORDER=3 CELLPADDING=12>

<TR>
<TD>Geetham</TD>
<TD>Sultan</TD>
<TD>Ibrahim</TD>
</TR>

<TR>
<TD>Kassim</TD>
<TD>Naseer</TD>
<TD>Purusoth</TD>
</TR>

</TABLE>

 
Geetham Sultan Ibrahim
Kassim Naseer Purusoth
The default value for this attribute is 1. The reason it is 1 and not 0 is so that any text in the cells won't be banging up against the borders. (Although you could specify 0 if you wanted to).


If we substitute CELLSPACING for CELLPADDING we get a slightly different effect.

<TABLE BORDER=3 CELLSPACING=12>

<TR>
<TD>Geetham</TD>
<TD>Sultan</TD>
<TD>Ibrahim</TD>
</TR>

<TR>
<TD>Kassim</TD>
<TD>Naseer</TD>
<TD>Purusoth</TD>
</TR>

</TABLE>

 
Geetham Sultan Ibrahim
Kassim Naseer Purusoth
The default value for the CELLSPACING attribute is 2.


We can, of course, use these attributes in combination.

<TABLE BORDER=3 CELLSPACING=12 CELLPADDING=12>

<TR>
<TD>Geetham</TD>
<TD>Sultan</TD>
<TD>Ibrahim</TD>
</TR>

<TR>
<TD>Kassim</TD>
<TD>Naseer</TD>
<TD>Purusoth</TD>
</TR>

</TABLE>

 
Geetham Sultan Ibrahim
Kassim Naseer Purusoth


 

<--BACK        NEXT-->
 
Introduction Lesson 1 Lesson 2 Lesson 3 Lesson 4 Lesson 5 Lesson 6

 

For enquiries and suggestions, contact the webmaster