Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add Asterisk to the end of a <label>

Tags:

html

css

forms

Is it possible to add an asterisk to the end of the textstring within <label>?

This is what I have, but the asterisk (of course) is displayed behind the whole label:

<label class="xy-form-label-required" for="zipcode">
   Zip Code
   <span class="xy-form-labelinfo">
       Allowed characters a-z A-z 0-9 ,.-
       Could also be an information about the field...
   </span>
</label>

My CSS Code:

form.xy-form .xy-form-label-required:after {
    color: grey;
    content: ' *';
}

This is the result:

Zip Code
Allowed characters a-z A-z 0-9 ,.-
*

This is what I want to achive without changing the html markup.

Zip Code *
Allowed characters a-z A-z 0-9 ,.-

like image 706
mayrs Avatar asked Jan 14 '23 13:01

mayrs


2 Answers

you can simply add the following CSS code instead

.xy-form-label-required > span.xy-form-labelinfo:before{
  color: grey;
  content: " *";
}
like image 168
Amyth Avatar answered Jan 17 '23 11:01

Amyth


Typo apart, you want the asterisk before the info label:

.xy-form-label-required .xy-form-labelinfo:before{
    color: grey;
    content: ' *';
}
like image 30
Álvaro González Avatar answered Jan 17 '23 09:01

Álvaro González