tags:

views:

38

answers:

3

Hi,

I always see the th tag only used in the first row of the table. Is there some specific reason why it can't be used to create 'left' headers along the leftmost column. Is this bad form, or is this ok.

Basically, a table with headings on the top row and the leftmost column, with the very top left square being empty.

e.g.

<table>
    <tr>
        <th/> <!--empty-->
        <th>Top 1</th>
        <th>Top 2</th></tr>
    <tr>
        <th>LeftHeader?</th>
        <td>data1</td>    
        <td>data2</td></tr>
</table>
+3  A: 

No, thats perfectly legit.

Daniel A. White
A: 

That's valid, however, when using a <thead> it has to be the first row. This is valid:

<table>
    <thead>
        <tr>
            <td>0,0</td><td>1,0</td><td>2,0</td>
        </tr>
    </thead>
    <tr>
        <th>0,1</th><th>1,1</th><th>2,1</th>
    </tr>
</table>

But this is not:

<table>
    <tr>
        <td>0,0</td><td>1,0</td><td>2,0</td>
    </tr>
    <thead>
        <tr>
            <th>0,1</th><th>1,1</th><th>2,1</th>
        </tr>
    </thead>
</table>

It's invalid HTML and you can double check that with the w3C markup validation service though before you do you'll have to add a <!DOCTYPE> declaration and the rest of a valid HTML doc.

LeguRi
A: 

your html code it's ok !

cosy