O'Reilly logo

Ajax: The Definitive Guide by Anthony T. Holdener III

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Accessible Tables

So far, I have only talked about what you should not use tables for, not really what you should use them for. Before exploring the tricks a developer can use to manipulate tables dynamically with Ajax, I want to take a brief look at the proper way to build a table in XHTML to make it accessible.

Most of the time, a user can look at a table with data and determine the table's purpose without much difficulty. However, people who are blind and use a page reader, for instance, do not have this luxury. In these and other cases, giving the user a caption for the table (much like every table title in this book) allows the user to quickly identify the table's purpose without having to look at the table. You use the <caption> element to give a table a caption, like this:

<table>
    <caption>Current Ajax Books from O'Reilly Media</caption>
    <tr>
        <td>Ajax and Web Services</td>
        <td>Mark Pruett</td>
        <td>August 2006</td>
    </tr>
    <tr>
        <td>Ajax Design Patterns</td>
        <td>Michael Mahemoff</td>
        <td>June 2006</td>
    </tr>
    ...
    <tr>
        <td>Your Life in Web Apps</td>
        <td>Giles Turnbull</td>
        <td>June 2006</td>
    </tr>
</table>

Giving a table a caption aids normal browser users, but to go further down the path to accessible tables, the developer should also provide a summary for the table. The summary attribute in the <table> element is used for this purpose, as this example shows:

<table summary="This table provides a list of current Ajax books from O'Reilly Media, broken down by title, author, and release ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required