How can I change the color of label with * in text

css, html

Solution

No, without javascript you won't be able to style only the `*`. what you will need to do is to put the `*` in its own element, and style that element.

Example:

HTML

<label> User Type<span>*</span>: </label>

CSS

label span { color: red; }

example fiddle: http://jsfiddle.net/Ee9L3/

EDIT: looks like i misread the question. No there's no way to do what you want. The easiest alternative would be to just add a class to the label.

HTML

<label class='required'>User Type*: </label>

CSS

label.required { color: red; }

Problem

I have labels like this `<label> User Type*: </label>` Now is there any way to change the color of label to red if text contains * in it only with CSS All I can do is edit `css`. I can't use Javascript.

Original source