Web Development and Design Foundations with XHTML, 5th Edition

(Steven Felgate) #1
8.1 Using Tables on Web Pages^319

attributes for <tr>, <th>, and <td>elements. Later in the chapter you’ll use CSS to
configure the background color, alignment, and width of these page areas.

The alignAttribute.This attribute can be used to align the contents of a table row
or table cell within a table. In Figure 8.12, the cells containing birthday information are
configured to be centered by the alignattribute on the <td>elements containing the
birthday information.

Figure 8.12
Table with birthday
information center-
aligned


The XHTML code for the table follows:
<table border="1">
<tr>
<th>Name</th>
<th>Birthday</th>
<th>Phone</th>
<th>E-mail</th>
</tr>
<tr>
<td>Jack</td>
<td align="center">5/13</td>
<td>847-555-5555</td>
<td>[email protected]</td>
</tr>
<tr>
<td>Sparky</td>
<td align="center">11/28</td>
<td>303-555-5555</td>
<td>[email protected]</td>
</tr>
</table>

The bgcolorAttribute.This deprecated attribute can be used to apply a back-
ground color to a table row or cell. See Figure 8.13 for an example of applying a back-
ground color to alternating rows of a table using this attribute.

Figure 8.13
Table using a
background color
on alternate rows


The XHTML code for the table follows:
<table border="0" cellpadding="10" cellspacing="0">
<tr bgcolor="#CCCCCC">
<th>Name</th>
<th>Birthday</th>
Free download pdf