Table Tutor - Lesson 8
Let's get rid of CELLPADDING and CELLSPACING and go back to our simple little table.
<TABLE BORDER=3>
<TR>
<TD>Ed</TD>
<TD>Tom</TD>
<TD>Rick</TD>
</TR>
<TR>
<TD>Larry</TD>
<TD>Curly</TD>
<TD>Moe</TD>
</TR>
</TABLE>
Ed
Tom
Rick
Larry
Curly
Moe
A cool feature of the newer browsers is the ability to specify background colors for a table cell, row or the whole table. You use BGCOLOR just like you would in the <BODY> tag.
<TABLE BORDER=3 BGCOLOR="#FF9933" >
<TR>
<TD>Ed</TD>
<TD>Tom</TD>
<TD>Rick</TD>
</TR>
<TR>
<TD>Larry</TD>
<TD>Curly</TD>
<TD>Moe</TD>
</TR>
</TABLE>
Ed
Tom
Rick
Larry
Curly
Moe
<TABLE BORDER=3>
<TR BGCOLOR="#FF6666" >
<TD>Ed</TD>
<TD>Tom</TD>
<TD>Rick</TD>
</TR>
<TR BGCOLOR="#66CCCC" >
<TD>Larry</TD>
<TD>Curly</TD>
<TD>Moe</TD>
</TR>
</TABLE>
Ed
Tom
Rick
Larry
Curly
Moe
<TABLE BORDER=3>
<TR BGCOLOR="#DD44DD" >
<TD>Ed</TD>
<TD>Tom</TD>
<TD>Rick</TD>
</TR>
<TR>
<TD BGCOLOR="#FF0000" >Larry</TD>
<TD>Curly</TD>
<TD BGCOLOR="#3366FF" >Moe</TD>
</TR>
</TABLE>
Ed
Tom
Rick
Larry
Curly
Moe
Here's a handy chart I use to choose background colors. There are also 2 charts in HTML format, one with 216 colors and another with 1536 colors . You can also use
Color Picker
for playing around with colors.
One more thing about these table background colors... a <TD> bgcolor will override a <TR> bgcolor and a <TR> bgcolor will override a <TABLE> bgcolor. Not that this needs further explanation but I'm kind of having fun with this so here's an example:
<TABLE BORDER=3 BGCOLOR="#FF6633" >
<TR BGCOLOR="#009900" >
<TD BGCOLOR="#9999FF" >Ed</TD>
<TD>Tom</TD>
<TD>Rick</TD>
</TR>
<TR>
<TD>Larry</TD>
<TD>Curly</TD>
<TD>Moe</TD>
</TR>
</TABLE>
Ed
Tom
Rick
Larry
Curly
Moe
FAQ: Can I use an image as a table background?
A: Yes, but... there is a catch. Learn about it here .