... and done properly you may not even need child classes...
Code:
<table class="yourClass">
<caption>
Describe table contents here, this is a header type element
</caption>
<colgroup>
<col align="left" />
<col align="center" />
<col align="center" />
<col align="center" />
</colgroup>
<thead>
<tr>
<th scope="col">Name</th>
<th scope="col">Quantity</th>
<th scope="col">Cost</th>
<th scope="col">Total</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">Mouse</th>
<td>1</td>
<td>4.99</td>
<td>4.99</td>
</tr><tr>
<th scope="row">Keyboard</th>
<td>1</td>
<td>6.99</td>
<td>6.99</td>
</tr><tr>
<th scope="row">Monitor</th>
<td>2</td>
<td>199.99</td>
<td>399.98</td>
</tr>
</tbody>
</table>
The header TH being isolated as ".yourClass tbody th", the data row TH being isolated as ".yourClass tbody th", the data row TD being ".yourclass tbody td", etc, etc.
The colgroups I put in there for browsers that don't recognize nth-child (legacy IE) or sibling selectors -- as well as CSS off alignment. It's one of the few situations presentation in the markup is acceptable. Firefox STILL doesn't inherit that property, so you'd want to be sure to target TR nth-child and/or sibling selectors thus:
Code:
.yourClass tr th {
text-align:left;
}
.yourClass tr td+td,
.yourClass tr th+th {
text-align:center;
}
<aside>(Gecko's failure to inherit ALIGN is 'kind-of' correct by the HTML spec, problem is it doesn't inherit ANY values properly -- see the 13 year old Bugzilla 915) for more</aside>
Bookmarks