A Complete Guide to Web Design

(やまだぃちぅ) #1
186 Chapter 10 – Tables

Affecting Table Appearance


Web Design in a Nutshell, eMatter Edition

Different effects can be created using different combinations of spacing and
padding. If you want your table to be seamless, as when it is holding together
an image, be sure to set the border, cellspacing, and cellpadding to 0, as
follows:
<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0>

Coloring Tables


You can specify a background color for the entire table (<table>), selected rows
(<tr>), or individual cells (<td>or<th>) by placing thebgcolorattribute in the
appropriate tag. Thebgcolorattribute is recognized by MSIE versions 2.0 and
higher and Navigator versions 3.0 and higher.
Color values can be specified either by their hexadecimal RGB values or by a stan-
dard color name. For more information on specifying color in HTML, see
Chapter 5,HTML Overview.
Color settings in a cell will override settings made at the row level, which over-
ride settings made at the table level. To illustrate, in the following example, the
whole table is set to light gray, the second row is set to medium gray, and the
furthest right cell in that row is set to dark gray. Figure 10-9 shows the results.
<TABLE BORDER=1 BGCOLOR="#CCCCCC">
<TR>
<TD></TD><TD></TD><TD></TD>
</TR>
<TR BGCOLOR="#999999">
<TD></TD><TD></TD><TD BGCOLOR="#333333"></TD>
</TR>
<TR>
<TD></TD><TD></TD><TD></TD>
</TR>
<TR>
<TD></TD><TD></TD><TD></TD>
</TR>
</TABLE>

Netscape Navigator and Internet Explorer treat background colors at the table level
differently. Navigator fills every cell in the table with the specified color, but the
border picks up the color of the document background. IE fills the entire table
area, including the borders, with the specified color for a more unified effect.
Background colors at the row and cell level are treated consistently by the two
browsers (although Navigator uses the document background color for empty
cells).

Figure 10-9: Effects of setting background colors at cell, row and table levels
Free download pdf