14

I'm trying to add content to something before an item using the CSS :before + content: fields. I want to insert a checkmark (☑), BUT if I use that in the content option, it prints as the literal. How can I tell CSS to make that a checkmark, not the literal string ☑?

sethvargo
  • 26,739
  • 10
  • 86
  • 156
  • The question formulation is obscure. It was probably meant to refer to notations like `☑` getting displayed literally (the explanation being that they have no special meaning in CSS), i.e. an attempt was made to use HTML “escapes” for characters in CSS. – Jukka K. Korpela Mar 26 '13 at 18:41

3 Answers3

29

Try this:

#target:before {
  content: "\2611";
}
sethvargo
  • 26,739
  • 10
  • 86
  • 156
Flack
  • 5,862
  • 2
  • 23
  • 27
6

You need to use Unicode values inside the content property. (The list of miscellaneous symbols may also be useful.)

A heavy checkmark is listed as U+2713 so you would put content: "\2713";

Brad Mace
  • 27,194
  • 17
  • 102
  • 148
3

Use the checkbox character literally in your CSS rule instead of the encoding -

#target:before {
    content: "☑";
}

See: http://jsfiddle.net/e3Wt2/

Yi Jiang
  • 49,435
  • 16
  • 136
  • 136