HTML and CSS Reference
In-Depth Information
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 align Attribute. 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 align attribute 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>jack04521@gmail.com</td>
</tr>
<tr>
<td>Sparky</td>
<td align="center"> 11/28</td>
<td>303-555-5555</td>
<td>sparky@iname.com</td>
</tr>
</table>
The bgcolor Attribute. 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>
 
Search WWH ::




Custom Search