Jump to content

Text align in table cells


george

Recommended Posts

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

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

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...