October 5, 2012

Accessibility considerations for tables

As we create tables, we must also deal with the accessibility of tables. The problem with table is that, we can see and differentiate between the rows and columns by our eyes, but it is difficult to differentiate for our ears linearly. And this makes an inaccessibility for blind. Here, in this post we will deal with this problem.

Using Summaries

Any table needs to answer the question, what this is all about, and it can be answered using the summary attribute in HTML.

<table summary="A brief overview of students marks according to their subjects">
     <caption>Student's Marks</caption>

     ...<!-- some codes missing -->


The value of summary won't be displayed, but it will be recognized and read out by screen readers. This brief description of what's going on can make table contents much easier and quicker to understand.

Using scope attribute

Though summary attribute can give the user to get an idea of what to expect, there is still much problem of describing the cells. Though, there are features like rowspan, colspan and grouping rows and columns, its still a problem to be read out along with the data itself.

Now, by the scope attribute, you can define what a header is for and can even denote the rowgroup(thead, tfoot and tbody), or colgroup. The value of this attribute can be row, col, rowgroup or colgroup.

<table border="1">
  <caption>Contact Information</caption>
    <th scope="col">Name</th>
    <th scope="col">Phone#</th>
    <th scope="col">Fax#</th>
    <th scope="col">City</th>
    <th scope="row">Joel Garner</th>
    <th scope="row">Clive Lloyd</th>
    <th scope="row">Gordon Greenidge</th>

As you can see from the above code, the scope attribute tries to differentiate between the row and column headers. But, these actions can't be seen on a user screen.

Using headers attribute

The headers attribute is useful for the accessibility and can be used within a td or th tag to specify which cells should be regarded as headers for it. The value can be a single id name or a list of ids separated by spaces.

     <th rowspan="2" id="h">Homework</th>
     <th colspan="3" id="e">Exams</th>
     <th colspan="3" id="p">Projects</th>
     <th id="e1" headers="e">1</th>
     <th id="e2" headers="e">2</th>
     <th id="ef" headers="e">Final</th>
     <th id="p1" headers="p">1</th>
     <th id="p2" headers="p">2</th>
     <th id="pf" headers="p">Final</th>
    <td headers="h">15%</td>
    <td headers="e e1">15%</td>
    <td headers="e e2">15%</td>
    <td headers="e ef">20%</td>
    <td headers="p p1">10%</td>
    <td headers="p p2">10%</td>
    <td headers="p pf">15%</td>

You can see from the above code and picture, how the headers carry the IDs and headers from the first to the last row. This clearly defines what values are under what headers.


  1. Hi Balaji,

    I love reading your blog. I have come across numerous tech blogs. But yours is unique with dedication and hardwork. This one would definitely reach heights.All my wishes for a great blogging career!

  2. Thankyou Jes, may your wishes come true!!!