Forum Moderators: not2easy

Message Too Old, No Replies

CSS to control a range of characters within a span

         

hockey2112

6:40 pm on Mar 13, 2009 (gmt 0)

10+ Year Member



Hi, I was wondering if anyone knew whether it was possible to use CSS to control only some of the text in a large block of text, all within the same span?

For instance, we have a span titled ProductsDetailBody. It includes the product name, description, item number, and price (all propagated on the page from separate database fields). I want to be able to change the price's font color without affecting the rest of the span's content, to hide it from view in certain cases. Is it possible to do this with CSS?

The price will always be the last thing in the ProductsDetailBody span... is there a way to use CSS to control only the last "so many" characters of a span? For instance, if the price encompasses the "last" 5 characters in the ProductsDetailBody span, can I use CSS to change the font color of those last five characters to a different color?

I know it would be easier to just add a span style for the price component, but we have extenuating circumstances that preclude me from doing that at this time. I look forward to your replies.

Thanks!

swa66

11:17 am on Mar 15, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



To select something inside an element without additional elements in it, there is only the pseudo elements ":first-line [w3.org]" and ":first-letter [w3.org]", none will do what you seek however.

hockey2112

4:08 pm on Mar 15, 2009 (gmt 0)

10+ Year Member



Bummer. Oh well, thanks for your input!