2 replies [Last post]
jst666
Offline
newbie
Helsinki
Last seen: 19 years 18 weeks ago
Helsinki
Joined: 2004-01-30
Posts: 2
Points: 0

So to the point. What I'd like to do, is to change color(or any other attribute) of character in a piece of text. In my case the character would be the last charactor of the text. Lemme tell you an example:

I have a form, which has some fields. One of the fields is required, and I'd like to note that with a red asterisk(or bold or whatever). If my required field should be "firstname", and my form:

Firstname *: __________
Lastname: __________

So why I don't want to use different style for the asterisk? I'm generating the code from a java-servlet framework, and that would be pain in the bottom. I could do this by using straight html, but that would make the underlying code somewhat... unreadable.

My first post here,
cheers for anyone who care to think about the problem,
and, ummm... the others as well,
j

karinne
karinne's picture
Offline
Enthusiast
Aylmer, QC, Canada
Last seen: 15 years 50 weeks ago
Aylmer, QC, Canada
Timezone: GMT-5
Joined: 2004-01-14
Posts: 291
Points: 0

Changing color of one character

hmmm... with css3 you will but no browser support that yet

http://www.w3.org/TR/2001/CR-css3-selectors-20011113/#content-selectors

http://www.w3.org/TR/2001/CR-css3-selectors-20011113/#pseudo-elements

i'm afraid the only way to do it now is using a <span> and assign a class like

css

.red { color: #900; }

html

Firstname <span class="red">*</span>: ....

jst666
Offline
newbie
Helsinki
Last seen: 19 years 18 weeks ago
Helsinki
Joined: 2004-01-30
Posts: 2
Points: 0

Changing color of one character

My thought too, which is sad...

So most likely I have to use:

Label l = new Label("Firstname <span class=\"required\">*</span>");
l.setContentMode(Label.CONTENT_XHTML);

Instead of:

Label l = new Label("Firstname *");
l.setStyle("required");

I'll keep looking,
for another way,
it's just readability,
j