CSS - select th tags only within the tbody of a table
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%"> </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>
.bgtable tbody th {
color: red;
}
table.bgtable tbody th {
/* CSS rules here */
}
tbody>tr>th {color:red;}
Although the previous are all valid, one can still be more precise (the css-selecting being not so performant).
table.bgtable > tbody > th {
color:red;
}
if you got more than one table, which doesn't belong to the class, you don't want to include it to your selection that's why "table.bgtable".
kwoning to you can embeded th with other tag withitn the tbody you would be sure to find them otherwise like that: table.bgtable > tbody th
精彩评论