Lesson 11

BACK

Use this Dropdown Box to find a quick
link to the page you are looking for.

o now you're ready to add a background color to your table. It's relatively simple. All you have to do is write bgcolor="#color" inside your TABLE tag, like this:

<TABLE bgcolor="#FFFFFF">

ow let's see it in action:

Roses Violets Lilies

This is the source:

<TABLE BORDER=3 BGCOLOR="#66ffff">

<TR>
<TD>Roses</TD>
<TD>Violets</TD>
<TD>Lilies</TD>
</TR>

</TABLE>

kay, what about making the cells several different colors? You can do that by adding a background color to each cell individually. You write in the TD tag like this:

<TD bgcolor="#FF0000"> Take a look at this:

<TABLE BORDER=3>

<TR>
<TD bgcolor="#FF0000">Roses</TD>
<TD bgcolor="#FFFFFF">Violets</TD>
<TD bgcolor="#0000FF">Lilies</TD>
</TR>

</TABLE>

And this is what it looks like:

Roses Violets Lilies

You can add color by table row also. Just write bgcolor="#color" inside your TR tag. You can make each row a different color like so:

Mon Tues Wed
Thurs Fri Sat

Check out the code:

<TABLE BORDER=3>
<TR BGCOLOR="#FF0000">
<TD>Mon</TD>
<TD>Tues</TD>
<TD>Wed</TD>
</TR>

<TR BGCOLOR="#33ccff">
<TD>Thurs</TD>
<TD>Fri</TD>
<TD>Sat</TD>
</TR>

</TABLE>


ow can you see how easy it is to add color? You can make each row or each cell any color you want.


Cellspacing & Cellpadding

et's talk about the TABLE attributes called CELLPADDING and CELLSPACING. Both are used in the <TABLE> tag. CELLPADDING is the amount of space between the border of the cell and the contents of the cell. And cellspacing is the amount of space BETWEEN cells. Here is an example of CELLPADDING. This puts more space between the contents and the edges of the cell.

Roses Violets Lilies
Zinnias Poppies Asters

Now take a look at the difference between CELLSPACING and CELLPADDING. There is now space BETWEEN the cells.

Roses Violets Lilies
Zinnias Poppies Asters

The default value for CELLPADDING is 1 and the default value for CELLSPACING is 2. To write in CELLSPACING and CELLPADDING, you simply place these attributes inside the TABLE tag, like so:

<TABLE cellspacing=10 cellpadding=10>

Now what if we wanted to use these attributes together. See for yourself below how this would look combining cellspacing and cellpadding:

Roses Violets Lilies
Zinnias Poppies Asters

Now you can set your tables the way you want them. That's it for this lesson. Now go practice your tables. Then move right along to Lesson 12.

 Lesson 12

E-mail Me!