HTML and CSS Reference
In-Depth Information
</tr>
<tr>
<th> Blue </th>
<td> Purple </td>
<td> Green </td>
<td> Blue </td>
</tr>
</table>
Finally, add a simple caption. The <caption> element goes just after the <table> tag and
just before the first <tr> tag:
<table border=“1”>
<caption> Mixing the Primary Colors </caption>
<tr>
With a first draft of the code in place, test the HTML file in your favorite browser that
supports tables. Figure 10.5 shows how it looks.
.
Output
FIGURE 10.5
The not-quite-
perfect color
table.
Oops! What happened with that top row? The headings are all messed up. The answer, of
course, is that you need an empty cell at the beginning of that first row to space the head-
ings out over the proper columns. HTML isn't smart enough to match it all up for you.
(This is exactly the sort of error you're going to find the first time you test your tables.)
Add an empty table heading cell to that first row. (Here, it's the line <th><br /></th> .)
Input
<tr>
<th><br /></th>
<th> Red </th>
<th> Yellow </th>
<th> Blue </th>
</tr>
 
Search WWH ::




Custom Search