Web Design / HTML

  1. Home
  2. Computing & Technology
  3. Web Design / HTML

Don't Forget the Missing Table Tags

Tags and Attributes That Will Make Your Tables More Accessible

By Jennifer Kyrnin, About.com

There are many ways you can make your tables more accessible, but the easiest is to use table tags that are already a part of the HTML specification. Here's how to use these tags (and an attribute) so that your HTML tables are accessible.

The <caption> Tag

Table captions are very common on tables in printed media, but for some reason, Web designers often leave them off of tables on Web pages. They are very easy to use, just add the caption text inside the <caption> tag right after you open your table:

<table style="width: 400px; border: 1px solid #000;">
<caption>Table 1.1: A record of the fur shed annually by Jennifer's dog, Shasta</caption>
<tr><th>Month</th><th>Fur Shed (mm)</th></tr>
</table>

See this example

To be valid, your caption tag should appear right after you open the table, no other location is valid. However, that doesn't mean that the caption has to appear at the top of the table. You can also make it appear to the right, left, or bottom - depending upon where you want it and where it makes the most sense. However, this property doesn't work in IE 6. Change the location with the caption-side style property:

<table style="width: 400px; border: 1px solid #000; caption-side: bottom;">
<caption>Table 1.1: A record of the fur shed annually by Jennifer's dog, Shasta</caption>
<tr><th>Month</th><th>Fur Shed (mm)</th></tr>
</table>

See this example

Because IE 5 and 6 are so popular, it's important to get the caption to display on the bottom in these browsers as well, if that's where you want it. So to get it working in IE, use the align attribute on the caption tag:

<table style="width: 400px; border: 1px solid #000; caption-side: bottom;">
<caption align="bottom">Table 1.1: A record of the fur shed annually by Jennifer's dog, Shasta</caption>
<tr><th>Month</th><th>Fur Shed (mm)</th></tr>
</table>

See this example

What to Use the Caption For

Captions provide additional information about the table. Since they typically appear above the table, you can use them as a title, but to make your tables accessible, you want to provide more information than that.

You can't include paragraphs within the caption element, but you can add quotations, anchors, and most text tags. Use these elements to provide the most complete caption you can without compromising the page. You don't need to summarize the entire table, we'll leave that to the attribute on page 2 - the summary attribute.

Did you find this article useful or interesting? Post a comment.

Explore Web Design / HTML

About.com Special Features

Build Your Own Website

Step-by-step advice on how to do everything from choosing a Web host to promoting your content. More >

Connect Your Home Computers

Easy ways to connect two computers for networking purposes. More >

Web Design / HTML

  1. Home
  2. Computing & Technology
  3. Web Design / HTML
  4. HTML and XHTML
  5. XHTML
  6. Tables
  7. Using Caption and Summaries to Make HTML Tables More Accessible

©2009 About.com, a part of The New York Times Company.

All rights reserved.