HTML and CSS Reference
In-Depth Information
NOTE
For table cells to show up with background colors, they must not be
empty. Simply putting a <br /> element in empty cells works fine.
Here's an example of changing the background and cell colors in a table. I've created a
checkerboard using an HTML table. The table itself is white, with alternating cells in
black. The checkers (here, red and black circles) are images. In the source code, I've used
both bgcolor and the background-color property to set background colors for some of
the cells. As you'll see in the screenshot, the appearance of both is the same when ren-
dered in the browser:
Input
<!DOCTYPE html>
<html>
<head>
<title> Checkerboard </title>
</head>
<body>
<table bgcolor=“#FFFFFF” width=“50%” summary=“checkerboard”>
<tr align=“center”>
<td bgcolor=“#000000” width=“33%”><img src=“redcircle.png” /></td>
<td width=“33%”><img src=“redcircle.png” alt=““ /></td>
<td bgcolor=“#000000” width=“33%”><img src=“redcircle.png” /></td>
</tr>
10
<tr align=“center”>
<td><img src=“blackcircle.png” alt=““ /></td>
<td style=“background-color: #000000”><br /></td>
<td><img src=“blackcircle.png” alt=““ /></td>
</tr>
<tr align=“center”>
<td bgcolor=“#000000”><br /></td>
<td><img src=“blackcircle.png” alt=““ /></td>
<td bgcolor=“#000000”><br /></td>
</tr>
</table>
</body>
</html>
Figure 10.17 shows the result.
 
Search WWH ::




Custom Search