george Posted December 2, 2010 Share Posted December 2, 2010 I have a table with text and dollar value columns. I want all my dollar value columns to be right justified, and all my text columns to be left justified. So I created this little bit of CSS: td { text-align:left; } td .RtJsty { text-align:right; } and I gave every dollar value holding cell the class RtJsty, like so: <tr><td>L 1. Beef with Broccoli</td><td class="RtJsty">$5.00</td></tr> <tr><td>L 2. Chickien with Broccoli</td><td class="RtJsty">$5.00</td></tr> It does not work. How should I do this? Link to comment Share on other sites More sharing options...
jeffman Posted December 2, 2010 Share Posted December 2, 2010 td .RtJsty Sounds trivial, but the space between the two selectors is the villain. It thinks you're looking for class RtJsty inside a td element. Just close the space and it will know you want a td element that is the class RtJsty. td.RtJsty Link to comment Share on other sites More sharing options...
dsonesuk Posted December 2, 2010 Share Posted December 2, 2010 remove space after td, with a space it will look for an element with class="RtJsty" directly after it, while td.RtJsty is a td with class RtJsty. Link to comment Share on other sites More sharing options...
george Posted December 2, 2010 Author Share Posted December 2, 2010 td .RtJsty Sounds trivial, but the space between the two selectors is the villain. It thinks you're looking for class RtJsty inside a td element. Just close the space and it will know you want a td element that is the class RtJsty. td.RtJsty Thank you both. This worked. But I still do not understand why. How is "class RtJsty inside a td element." different from "a td element that is the class RtJsty"How would the class be identified differently in the HTML? Ok, this looks to me like "a td element that is the class RtJsty" <td class="RtJsty" So what would a class inside a td element be? Sorry for my confusion. Is there a reason to have the space there in certain instances?(thinking of changing my handel to everDnewbe) Link to comment Share on other sites More sharing options...
jeffman Posted December 2, 2010 Share Posted December 2, 2010 With the space, it's looking for something like this: <td><p class="RtJsty">something</p></td> The <p> of class "RtJsty" is a child of the <td>. It wouldn't have to be a <p> either, since with the space you defined only a class, not a class of something. td.RtJsty means "RtJsty" is a class of td only.I could have expressed myself a little better, maybe. Link to comment Share on other sites More sharing options...
george Posted December 2, 2010 Author Share Posted December 2, 2010 Ok, now I got it. Thanks for taking the time to set me straight. I now have something to look out for when debugging other sites. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.