Proposal HTP03
Enhanced RULES Support in HTML Tables

Stephen Ferg, Bureau of Labor Statistics
Contact Info
Revised: August 8, 2002

For the best results when printing this page, set your browser's font size to SMALLEST.

Introduction

A problem with the current HTML specification is that is does not allow sufficiently precise control over the rules (lines) in tables. This makes it impossible to produce statistical data tables with a satisfactory appearance. This deficiency can easily be remedied by allowing more precise control over table rules by supporting HEADRULES, BODYRULES, and FOOTRULES attributes of the TABLE element.

Background

In statistical data tables, it is common for the table headers to be formatted differently from the table body. Specifically, it is common for the table body to be formatted as if RULES="groups" or RULES="cols" had been specified, while the table header (the rows in THEAD) are formatted as if RULES="all" had been specified.

We can approximate the appearance of a typical statistical data table using features in the current HTML specification, by using two tables, one for the headings, and one for the body. Note that we have specified the FRAME="HSIDES" attribute on the TABLE tag, thus removing the left and right sides of the frame around the table.

Demo Table
HEADER A Header B Header C
Header B1 Header B2 Header C1 Header C2
CATEGORY A   999.99   999.99   999.99   999.99  
CATEGORY B   999.99   999.99   999.99   999.99  
         
CATEGORY C   999.99   999.99   999.99   999.99  
CATEGORY D   999.99   999.99   999.99   999.99  

Discussion

We propose adding support for HEADRULES, BODYRULES, and FOOTRULES attributes of the TABLE element. These attributes would take the same set of values that the RULES attribute takes.

With these attributes available, tables will be rendered as they are according to the current HTML specification, with the exception that if a HEADRULES attribute is specified it should over-ride the RULES value for rows in the THEAD part of the table. And similarly for BODYRULES and TBODY rows, and FOOTRULES and TFOOT rows.

If these features were to be supported in HTML, a table that is rendered like the one above could be coded this way.



<table border="1" cellspacing="0" frame="hsides" rules="groups" headrules="ALL"
 cellpadding="0" align="CENTER" width="75%">
<caption>Demo Table</caption>

<colgroup>
<col width="15%" />
</colgroup>

<colgroup>
<col width="15%" /><col width="15%" />
</colgroup>

<colgroup>
<col width="15%" /><col width="15%" />
</colgroup>


<thead>
<tr>
<th class="center" rowspan="2"> HEADER A </th>
<th class="center" colspan="2"> Header B </th>
<th class="center" colspan="2"> Header C </th>
</tr>


<tr>
<th class="center" colspan="1"> Header B1 </th>
<th class="center" colspan="1"> Header B2 </th>
<th class="center" colspan="1"> Header C1 </th>
<th class="center" colspan="1"> Header C2 </th>
</tr>
</thead>


<tbody>
<tr>
<th class="left"> CATEGORY A &nbsp;</th>
<td> 999.99 &nbsp; </td><td> 999.99 &nbsp; </td><td> 999.99 &nbsp; </td><td> 999.99 &nbsp; </td>
</tr>

<tr>
<th class="left"> CATEGORY B &nbsp;</th>
<td> 999.99 &nbsp; </td><td> 999.99 &nbsp; </td><td> 999.99 &nbsp; </td><td> 999.99 &nbsp; </td>
</tr>

</tbody>

<tbody>
<tr>
<th class="left"> &nbsp;</th>
<td> &nbsp; </td>
<td> &nbsp; </td>
<td> &nbsp; </td>
<td> &nbsp; </td>
</tr>
</tbody>

<tbody>

<tr>
<th class="left"> CATEGORY C &nbsp;</th>
<td> 999.99 &nbsp; </td><td> 999.99 &nbsp; </td><td> 999.99 &nbsp; </td><td> 999.99 &nbsp; </td>
</tr>

<tr>
<th class="left"> CATEGORY D &nbsp;</th>
<td> 999.99 &nbsp; </td><td> 999.99 &nbsp; </td><td> 999.99 &nbsp; </td><td> 999.99 &nbsp; </td>
</tr>

</tbody>
</table>