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>
To select the very first <tr> element after a <caption> element, you can instead use: caption + tbody tr:first-child { ... }
Quoting the HTML 4 spec: "The TBODY start tag is always required except when the table contains only one table body and no table head or foot sections. The TBODY end tag may always be safely omitted."
The <tbody> tag is used to group the body content in an HTML table. The <tbody> element is used in conjunction with the <thead> and <tfoot> elements to specify each part of a table (body, header, footer). Browsers can use these elements to enable scrolling of the table body independently of the header and footer.
You may use more than one <tbody> per table as long as they are all consecutive.
.bgtable tbody th {
color: red;
}
table.bgtable tbody th {
/* CSS rules here */
}
tbody>tr>th {color:red;}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With