Sams Teach Yourself HTML 4 in 24 Hours

Sams Teach Yourself HTML 4 in 24 Hours

By Dick Oliver

Backgrounds and Spacing

There are a few tricks in Figures 15.3 and 15.4 that I haven't mentioned yet. You can give an entire table—and each individual row or cell in a table—its own background, distinct from any background you might use on the Web page itself. You do this by placing a bgcolor or background attribute in the <table>, <tr>, <td>, or <th> tag exactly as you would in the <body> tag (see Hour 11, "Custom Backgrounds and Colors" ). To give an entire table a yellow background, for example, you would use <table bgcolor="yellow"> or the equivalent <table bgcolor="#ffff00">

You can also control the space around the borders of a table with the cellpadding and cellspacing attributes. The cellspacing attribute sets the amount of space (in pixels) between table borders and between table cells themselves. The cellpadding attribute sets the amount of space around the edges of information in the cells. Setting the cellpadding value to 0 causes all the information in the table to align as closely as possible to the table borders, possibly even touching the borders. cellpadding and cellspacing give you good overall control of the table's appearance.

You saw the effect of background color and spacing attributes in Figures 15.3 and 15.4.

Share ThisShare This

Informit Network