Re: Why use SCOPE instead of TH

Bailey, Bruce schrieb:
> The question came up on tonight’s call as to why an author would use SCOPE instead of TH for a data table with only one level of row or column headings.  I thought I would share a couple of scenarios I have encountered with some regularity.  I agree these are not *great* reasons for the technique, but I am comfortable asserting they are at least minimally acceptable.
> 
> 1)  The author is not comfortable with CSS and finds the default formating effects associated with TH to be undesirable.  Adding a SCOPE attribute to a TD tag is a straightforward fix.
> 
> 2)  TH tags do not *always* appear in the topmost row or the leftmost column.  The value associated with a SCOPE attribute programatically resolves any ambiguity as to if a TH applies to a row or column.

3) A cell may be data according the column header, but act as a header 
for the row. The HTML 4.01 specification says:

<!-- TH is for headers, TD for data, but for cells acting as both use TD -->

According to this the proper markup would be a td (with scope="row").

Example:

<table>
   <caption>Results 100m Men</caption>
   <thead>
     <tr>
       <th scope="col">Rank</th>
       <th scope="col">Name</th>
       <th scope="col">Time</th>
     </tr>
   </thead>
   <tbody>
     <tr>
       <td scope="row">1</td>
       <td>Freddy Fast</td>
       <td>11.07</td>
     </tr>
     ...
     <tr>
       <td scope="row">8</td>
       <td>Stephen Slow</td>
       <td>13.49</td>
     </tr>
   </tbody>
</table>
-- 
Johannes Koch
Spem in alium nunquam habui praeter in te, Deus Israel.
                          (Thomas Tallis, 40-part motet)

Received on Friday, 26 January 2007 07:50:59 UTC