Re: Explanation on usage of 'td' vs 'th' within a thead

Hi Giovanni,

That's a good example to work with, thanks!

But let's see here; I'd argue that every cell in the thead is actually  
a 'th'.  Here's why:  The second row headers (Salary., Food., Transp.,  
and Entert.) are still acting as headers to the body cells, and so  
should be headers.  However, the first row headers other than Month,  
Incomes and Outcomes, are acting as headers to these second row headers.
Also, considering the body cells--their headers attribute would likely  
reference both cells from the first thead row and the second thead row  
(well, except the month column cells). For example, the '€  1500' has  
related header cells of both 'Incomes' and 'Salary'.  The spec  
requires that cells referenced by a headers attribute be 'th'  
themselves, further solidifying these two rows in the thead as header  
cells.

So I'm still stuck on this general idea, that if a cell is in a thead,  
it must be serving as a header cell for body cells.  But, your example  
highlights a perfectly valid scenario where some header cells might be  
serving as headers for other headers within the thead.

I think you are right; td/th are options simply because of the content  
model of tr.  I'd hope, though, that if there is no reason to use td  
within a thead, that the spec could indicate that by adding a  
restrictive condition to the tr content model when in a thead.

To help clarify, I wanted to convert your example, and then my  
argument, to HTML:

Original example
================
<table>
     <thead>
         <tr><th>Month</th><th>Incomes</th><th>Outcomes</th></tr>
         <tr><td>Salary</td><td>Other></td><td>Food></th><td>Transp.</ 
td><td>Entert</td></tr>
     </thead>
     <tbody>
         <tr><td>Jan</td><td>€  1500</td><td>€  85</td><td>€  720</ 
td><td>€  310</td><td>€  150</td></tr>
     </tbody>
</table>

Re-interpretation
=================
<table>
     <thead>
         <tr><th id="month">Month</th><th id="incomes">Incomes</th><th  
td="outcomes">Outcomes</th></tr>
         <tr><th id="salary" headers="incomes">Salary</th><th  
id="other" headers="incomes">Other></th><th id="food"  
headers="outcomes">Food></th><th id="transp"  
headers="outcomes">Transp.</th><th id="entert"  
headers="outcomes">Entert</th></tr>
     </thead>
     <tbody>
         <tr><td headers="month">Jan</td><td headers="incomes salary"> 
€  1500</td><td headers="incomes other">€  85</td><td  
headers="outcomes food">€  720</td><td id="outcomes transp">€  310</ 
td><td headers="outcomes entert">€  150</td></tr>
     </tbody>
</table>

On Jul 22, 2009, at 4:41 AM, Giovanni Campagna wrote:

> 2009/7/22 Seth Call <sethcall@gmail.com>:
>> Hey there,
>>
>> I know I'd personally benefit from an explanation of the usage of  
>> 'td'
>> versus 'th' in a thead.
>>
>> Why would someone ever put a 'td' in a thead?  Related question...  
>> why would
>> put in a mix of td's and th's within a thead?
>>
>> Maybe It's just a lack of creativity on my part, or a lack of  
>> experience
>> with tables, but after reading the spec, I still don't understand  
>> why I'd
>> use td vs a th in a thead; morever, I don't have a good reason why  
>> I'd mix
>> the two in a single thead.
>>
>> Thanks!
>>
>> Seth
>>
>
>
> Uhm... Look at
> |=========================================================|
> | Month |   Incomes           |          Outcomes         |
> |       | Salary |   Other    | Food  | Transp. | Entert. |
> |=========================================================|
> | Jan   |€  1500 | €       85 | € 720 | €   310 | €   150 |
> | Feb   |€  1500 | €       85 | € 685 | €   380 | €   210 |
> /etc/
>
> headings in the second row can be marked as <td> because they're
> actually data (the reason for spending / earning money)
>
> However, it is more realistic that <td> are allowed as descendant of
> <thead> just because <tr> have always the same content model
> ((td,th)+).
>
> Giovanni

Received on Wednesday, 22 July 2009 13:45:50 UTC