W3C home > Mailing lists > Public > whatwg@whatwg.org > February 2011

[whatwg] Proposals for better support of Tables

From: Alexandre Morgaut <Alexandre.Morgaut@4d.com>
Date: Mon, 7 Feb 2011 21:59:01 +0100
Message-ID: <C282E02B-2BA6-455A-B275-DCC8B3D8621A@4d.com>

The HTML Table API provides powerful attributes like:
- "scope"
- "headers"
- "colspan"
- "rowspan"

All of them give informations about relationships between the table cells, rows, and columns

It would be very helpful if:
 - each "th" element could have a "cells" property which would be the HTML Collection of each "td" they are heading
 - each "td" element could have a "headerCells" property which would be the HTML Collection of each of their related "th"
 - each cell element could have "rows" and "columns" properties which would be the HTML collection of each rows and columns covered by their rowspan and colspan attributes

Actually we can use getElementByClassName(), so we often see

<tr><th id="th1" colspan="2">MySection</th></tr>
<tr><th id="th2" class="child-of-th1" scope="row">MyName</th><td>MyData</td></tr>
<tr><th id="th3" class="child-of-th2" scope="row">+ MySubName</th><td>MySubData</td></tr>
  
instead of

<tr><th id="th1" colspan="2">MySection</th></tr>
<tr><th id="th2" headers="th1" scope="row">MyName</th><td>MyData</td></tr>
<tr><th id="th3" headers="th1 th2" scope="row">+ MySubName</th><td>MySubData</td></tr>
  
which would be semantically more expressive and better for screenreaders


About "headers" I wonder if this would be acceptable:

<tr><th id="th1" colspan="2">MySection</th></tr>
<tr><th id="th2" headers="th1" scope="row">MyName</th><td>MyData</td></tr>
<tr><th id="th3" headers="th2" scope="row">+ MySubName</th><td>MySubData</td></tr>

as for the third row, the th1 header is implicit from the th2 declared header
Received on Monday, 7 February 2011 12:59:01 UTC

This archive was generated by hypermail 2.3.1 : Monday, 13 April 2015 23:09:03 UTC