views:

292

answers:

3

I would like to use a css selector to get only the th tags with the tbody. There are also th tags in the thead section, which I don't want included by the selector. Here's the markup I'm working with. Is there a selector to accomplish this?

<table class="bgtable">
<thead><tr><td width="40%">&nbsp;</td>
<th class="tdplain">Grade 4</th>
<th class="tdplain">Grade 8</th>
<th class="tdplain">Grade 12</th>
</tr>
</thead>
<tbody><tr><th class="tdplain">Civics (2010)</th>
<td class="tdplain">769K</td>
<td class="tdplain">577K</td>
<td class="tdplain">1179K</td>
</tr>
</tbody>
</table>
+7  A: 
.bgtable tbody th {
   color: red;
}
jessegavin
A: 
table.bgtable tbody th {
 /* CSS rules here */
}
Matt Ball
I don't think that's actually true. http://www.w3.org/TR/html4/struct/tables.html#h-11.2.5 <- row groups contain `TRs`. `TRs` contain `TH|TD`. Can you link the spec that says you can't have a `TH` in `TBODY`?
Joel Potter
I 2nd Joel's comment. I can't find any spec that says you can't have a `TH` in a `TBODY`.
jessegavin
The W3C Validator's been a little slow this morning. I finally got it to load and ran a test - you guys are right!
Matt Ball
Out of curiosity, why the downvotes? My answer is effectively the same as the accepted one. I don't mind being downvoted but comments are appreciated.
Matt Ball
A: 
tbody>tr>th {color:red;}
dirq