19

I can't change the color on the following characters:

<div style="font-size: 25px; color:red;">&#128269;</div>
<div style="font-size: 25px; color:red;">&#128227;</div>

While some other Unicode characters accept a color property:

<div style="font-size: 25px; color:red;">&#9881;</div>

Is there a way to change color on the previous characters?

https://jsfiddle.net/cs5053ka/

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
fcaserio
  • 726
  • 1
  • 9
  • 18

2 Answers2

17

On many systems, emoji characters like and are drawn differently from regular characters. While symbols like % are drawn by filling in a vector outline, emoji are often drawn using a full-color bitmap that doesn't respect your text color.

To change the color of an emoji character, you have a few options:

  • Manually recolor the emoji in an image editor and use an <img> tag or CSS background image to display it.
  • Use a web icon font like Font Awesome that includes similar-looking icons. Icon fonts are drawn with vector outlines just like regular symbols, so the color property works on them.
  • Use a text-shadow hack to fill the emoji with a solid color.

You can also use a variation selector to turn certain emoji into regular characters that can be recolored, but this doesn't work for or .

Community
  • 1
  • 1
Carter Sande
  • 1,789
  • 13
  • 26
  • 2
    Nice. I was beating my head against the wall on changing the color of a unicode PLUS sign. Changing it to a different unicode character worked. I didn't realize that some of the simple characters are bitmaps. – mwilcox Apr 17 '17 at 17:07
1

Another approach is to use variation selector-15, given some codes can have a text form (check this table, extracted from this answer, and this one too). If it is the case, one can apply colors as a plain text. The trick is just to append 65038 (or xFE0E) after your Unicode character, like this:

<span>&#128269;&#65038;</span>   <!-- ︎ -->

<div style="font-size: 25px;">
  <span style="color:red;">&#128269;&#65038;</span>
  <span style="color:green;">&#128269;&#65038;</span>
  <span style="color:blue;">&#128269;&#65038;</span>
</div>
<div style="font-size: 25px;">
  <span style="color:red;">&#x1F508;&#65038;</span>
  <span style="color:green;">&#x1F508;&#65038;</span>
  <span style="color:blue;">&#x1F508;&#65038;</span>
</div>
l30.4l3x
  • 365
  • 1
  • 4
  • 6