A narrative follows the examples.
The table lists travel expenses at two locations: San Jose and Seattle, by date, and category (meals, hotels, and transport). The following image shows how a visual user agent might render the table.
This first example uses
th codes appropriately
(and even uses
but is not accessible because it has two levels of row heading (city and date) but does not use any HTML attributes or tags to reflect this.
This second example adds the
It satisfies the standards for accessible complex data tables.
The above examples illustrates how to create an accessible “complex” table.
Complex tables are those “data tables that have two or more logical levels of row or column headers”.
These samples are adapted from the
W3C WAI WCAG Techniques
These examples also include
colspan, but all cells have some content (but for some cell that means a single non-breaking space).
In order to help tracking with a screen reader, the dollar and cents values (which constitute the bulk of the table content) have been changed to reflect table row and column postion (for example, 102.03 would reprectent table one, row two, column three) but the totals and subtotals are no longer accurate.
A similar technique is used for the dates.
Please note that the example graphic is a highly idealized, as shading and multiple border styles are used to suggest relationships among the rows and columns. If desired, these visual elements could be achieved with CSS.