Chapter 4 : Tables

Tables on the web pages are quite common. Anytime where a data content is displayed on the page with rows and columns an HTML table may be used.
In the previous chapter we discussed about the charts and graphs. We said that the substitute for charts and graphs are tables.
The literacy rate in various states in India between 2001 and 2010 if provided using a table, it can be displayed as follows.

  1. Each year from 2001 to 2010 are column headers.
  2. Each state will be the row header.
  3. The actual content will be the intersection of the rows and columns.

Since this is a simple table with equal number of cells in each column or row, in other words no spanning of rows and columns are in the table, the following elements and attributes can be used to make the table accessible.

  1. All the header cells i.e. years from 2001 to 2010 and names of the states must be marked with <th> element.
  2. All the modern screen readers and browsers are taking care of the header and data cell relationship when the <th> element is used, however for consistency across screen readers and browsers add the scope attribute within the header cels. i.e. scope=‘col’ for column header and scope=‘ row’ for the row header.
  3. The <td> element must be used for the data cells.
  4. The <caption> element though optional can be used to add a heading to the table.