How to prevent Unicode characters from rendering as emoji in HTML from JavaScript?
Append the Unicode variation selector character for forcing text, VS15, ︎
.
This forces the previous character to be rendered as text rather than as an Emoji Symbol.
<p>🔒︎</p>
Result: 🔒︎
Learn more at: Unicode symbol as text or emoji
I had a Unicode character in the content
of a span::before
, and I had the font-family
of the span
set to "Segoe UI Symbol". But Chrome used "Segoe UI Emoji" as the font to render it.
However, when I set the font-family
to "Segoe UI Symbol" explicitly for the span::before
, rather than just for the span
, then it worked.
For a CSS-only solution to prevent iOS displaying emojis, you can use font-family: monospace
which defaults to the text variant of the glyph rather than the emoji variant.