Friday, December 25, 2009

Section 13.7. Adding a caption and a summary










13.7. Adding a caption and a summary




There are a couple of things you can do right off the bat to improve your tables, like adding a caption and a summary.



<table summary="This table holds data about the cities I visited on my travels.
I've included the date I was in each city, the temperature when I was there, and altitude
and population of each city. I've also included a rating of the diners where I had lunch,
on a scale from 1 to 5.">
The summary doesn't appear in the Web page display. This is purely for
accessibility, and acts as a bit of text a screen reader may read aloud to a user to
describe the table.

<caption>
The caption, on the other hand, is displayed in the browser. By default,
most browsers display this above the table.

The cities I visited on my
Segway'n USA travels
If you don't like the default location of the caption, you can use CSS to
reposition it (we'll give that a try in a sec), although some browsers don't fully support
repositioning the caption yet.

</caption>
<tr>
<th>
City</th>
<th>Date</th>
<th>Temperature</th>
<th>Altitude</th>
<th>Population</th>
<th>Diner Rating</th>
</tr>
<tr>
<td>
Walla Walla, WA</td>
<td>
June 15th</td>
<td>
75</td>
<td>
1,204 ft</td>
<td>
29,686</td>
<td>
4/5</td>
</tr>
<tr>
<td>
Magic City, ID</td>
<td>
June 25th</td>
<td>
74</td>
<td>
5,312 ft</td>
<td>
50</td>
<td>
3/5</td>
</tr>

.
.
.
The rest of the table rows go here.

</table>













No comments: