To answer your question directly: no . There is no simpler way to get a consistent look in all modern browsers without repeating the class in a column. (Although, see below re: nth-child.)
The following is the most effective way to do this.
HTML:
<table class="products"> <tr> <td>...</td> <td>...</td> <td class="price">10.00</td> <td>...</td> <td>...</td> </tr> <tr> <td>...</td> <td>...</td> <td class="price">11.45</td> <td>...</td> <td>...</td> </tr> </table>
CSS
table.products td.price { text-align: right; }
Why you should not use nth-child:
The CSS3 pseudo-selector, nth-child, would be ideal for this - and much more efficient - but it is not practical for use on a real network, as it exists today. It is not supported by several major modern browsers , including all IE from 6-8. Unfortunately, this means that nth-child is not supported in a significant proportion (at least 40%) of browsers today.
So nth-child is awesome, but if you want a consistent look, it is just not practical to use it.
Matt Howell Aug 26 '09 at 6:16 2009-08-26 06:16
source share