I would like to add a CSS class name “currency” to the header (th) of my table’s column and have all the children data cells (td) in the column align to the right.
My best attempt is :
table th.currency td {
text-align: right;
}
However this obviously does NOT work. I tried to make it direct descendants “>” but that didn’t work either.
I’d like to avoid adding the individual “currency” class name to ALL the td cells. Anybody got a solution?
Using jQuery:
Working jsFiddle: http://jsfiddle.net/8XSLF/
If the currency class doesn’t right align, you can use the css function instead:
This can be put in a script shared among many pages, but can’t be done with just CSS alone.