Jump to content

<th> Semantics


Cipater2

Recommended Posts

Just a quick question about semantics here regarding the <th> tag...In my page I have a couple of 2-column tables. I want to have all the entries in the first column of each table to be bold, and with a colored background, and I'm currently doing this by assigning a class to each type of cell and assigning styles in my stylesheet. My HTML basically looks like this:

<table><tr><td class="msmnt_name">A MEASUREMENT</td><td class="msmnt_value">A Value</td></tr><tr><td class="msmnt_name">ANOTHER MEASUREMENT</td><td class="msmnt_value">Another Value</td></tr></table>

The question is: can I use <th> and <td> tags like in the below example and still be semantically correct? An end result might look like the following:

<table><tr><th>WAIST</th><td>30 inches</td></tr><tr><th>INSEAM</th><td>32 inches</td></tr><tr><th>RISE</th><td>4 inches</td></tr></table>

I'm not sure if this is still semantically correct because the headers span the first column of the table, rather than spanning the first row as I've seen in every example of the <th> tag...Thanks in advance!

Link to comment
Share on other sites

Looks good to me.

<TABLE border="1"		  summary="This table gives some statistics about fruit				   flies: average height and weight, and percentage				   with red eyes (for both males and females)."><CAPTION><EM>A test table with merged cells</EM></CAPTION><TR><TH rowspan="2"><TH colspan="2">Average	<TH rowspan="2">Red<BR>eyes<TR><TH>height<TH>weight<TR><TH>Males<TD>1.9<TD>0.003<TD>40%<TR><TH>Females<TD>1.7<TD>0.002<TD>43%</TABLE>

from : http://www.w3.org/TR/html401/struct/tables.html#h-11.1

Link to comment
Share on other sites

Not required, but a good idea to include them. Good programming. Also, I'm not certain if the lack of end tags will work in xHtml, if you are using that.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...