[whatwg] Proposals for better support of Tables

Alexandre Morgaut Alexandre.Morgaut at 4d.com
Mon Feb 7 12:59:01 PST 2011


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




More information about the whatwg mailing list