Table Tutor- Lesson 2

Ok, what we've got is this...

<TABLE>
<TR>
<TD>Ed</TD>
</TR>
</TABLE>

...which gives us this:

Ed




First lets make it look more like a table and give it a border. Every time you make a change and want to see how it looks, you can hit the Reload button on your browser. If your browser doesn't have a reload button, get another browser.

<TABLE BORDER=1>
<TR>
<TD>Ed</TD>
</TR>
</TABLE>

Ed


How about a bigger border?

<TABLE BORDER=5>
<TR>
<TD>Ed</TD>
</TR>
</TABLE>

Ed


How about a HUGE border?

<TABLE BORDER=25>
<TR>
<TD>Ed</TD>
</TR>
</TABLE>

Ed


How about NO border?

<TABLE BORDER=0>
<TR>
<TD>Ed</TD>
</TR>
</TABLE>

Ed

As you can see, the default is no border.


Let's stick with a modest border for now.

<TABLE BORDER=3>
<TR>
<TD>Ed</TD>
</TR>
</TABLE>

Ed


When no sizes are specified the table is only as big as it needs to be.

<TABLE BORDER=3>
<TR>
<TD>Ed, Rick and Tom</TD>
</TR>
</TABLE>

Ed, Rick and Tom


Specifying a table size is pretty simple though.

<TABLE BORDER=3 WIDTH=100%>
<TR>
<TD>Ed, Rick and Tom</TD>
</TR>
</TABLE>

Ed, Rick and Tom


How about this?

<TABLE BORDER=3 WIDTH=75%>
<TR>
<TD>Ed, Rick and Tom</TD>
</TR>
</TABLE>

Ed, Rick and Tom


Let's get rid of Ed's friends for now.

<TABLE BORDER=3 WIDTH=75%>
<TR>
<TD>Ed</TD>
</TR>
</TABLE>

Ed


Let's reduce the table size to 50% of the browser window.

<TABLE BORDER=3 WIDTH=50%>
<TR>
<TD>Ed</TD>
</TR>
</TABLE>

Ed


Now we will specify a width of 50 instead of 50%.

<TABLE BORDER=3 WIDTH=50>
<TR>
<TD>Ed</TD>
</TR>
</TABLE>

Ed


Now 100.

<TABLE BORDER=3 WIDTH=100>
<TR>
<TD>Ed</TD>
</TR>
</TABLE>

Ed
As you can see there are two ways to specify table width. Each style has its uses. Which style to use for what is unimportant now.


We can also mess around with the height.

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

Ed

I'm reminded of something Steven Wright said...

"The other day, I was walking my dog around my building...on the ledge. Some people are afraid of heights. Not me, I'm afraid of widths."


We can control where in the cell the data will appear.

<TABLE BORDER=3 WIDTH=100 HEIGHT=75>
<TR>
<TD ALIGN=CENTER>Ed</TD>
</TR>
</TABLE>

Ed


<TABLE BORDER=3 WIDTH=100 HEIGHT=75>
<TR>
<TD ALIGN=RIGHT>Ed</TD>
</TR>
</TABLE>

Ed


<TABLE BORDER=3 WIDTH=100 HEIGHT=75>
<TR>
<TD ALIGN=LEFT>Ed</TD>
</TR>
</TABLE>

Ed
As you can see, the default value is ALIGN=LEFT. You probably already know, by the way, that the default value is the value that the browser assumes if you have not told it otherwise.


We can also control where data will appear vertically in a cell.

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

Ed


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

Ed


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

Ed
Default is middle.


I will take a second now to show you something else. Images can also be used and manipulated in a table data cell. In the folder that contains this document you will find a small picture named ed.gif. Copy it into the folder that you are working out of (the one where you put tables1.html). Substitute an IMG tag for Ed.

<TABLE BORDER=3 WIDTH=100 HEIGHT=75>
<TR>
<TD ALIGN=LEFT VALIGN=MIDDLE><IMG SRC="ed.gif" WIDTH=32 HEIGHT=32></TD>
</TR>
</TABLE>

I suppose that now is also a good time to stress that it is good practice to include size attributes with all your image tags. I won't go into details, but doing so makes it easier for the browser and avoids any nasty little surprises.


<--BACK        NEXT-->

Introduction Lesson 1 Lesson 2 Lesson 3 Lesson 4 Lesson 5 Lesson 6 Lesson 7 Index
PROFESSIONAL WEB DESIGN