CSS Content special character : Hex vs normal character

l2aelba picture l2aelba · Mar 27, 2013 · Viewed 9.2k times · Source

Example 'BLACK STAR' ★ (U+2605)

.a:after {
   content: "\2605";
   position:absolute;
}

.b:after {
   content: "★";
   position:absolute;
}

Demo : http://jsfiddle.net/l2aelba/vBjxX/

Why someone/most recommended to use HEX like \2605 in CSS value ? Both get a same result.

Answer

dsgriffin picture dsgriffin · Mar 27, 2013

It is always better to use the actual values instead of hard-coding special characters like your bottom example as there's a possibility they won't show up correctly due to the encoding of the CSS file itself.