180

I'm finding Unicode for special characters from FileFormat.Info's search.

Some characters are rendering as the classic black-and-white glyphs, such as ⚠ (warning sign, \u26A0 or ⚠). These are preferable, since I can apply CSS styles (such as color) to them.

image of warning glyph

Others are rendering as newer cartoony emoji, such as ⌛ (hourglass, \u231B or ⌛). These are not preferable, since I cannot fully style them.

image of hourglass emoji

It appears that the browser is making this change, since I'm able to see the hourglass glyph on Mac Firefox, just not Mac Chrome nor Mac Safari.

Is there a way to force browsers to display the older (flat monotone) versions to display?

Update: It seems (from comments below) there is a text presentation selector, FE0E, available to enforce text-vs-emoji. The selector is concatenated as a suffix without space onto the character's code, such as ⌛︎ for HTML hex or \u231B\uFE0E for JS. However, it is simply not honored by all browsers (eg Chrome and Edge).

Arithmomaniac
  • 4,604
  • 3
  • 38
  • 58
  • do you set a font-family in your CSS rules? – G-Cyrillus Oct 02 '15 at 20:59
  • 2
    Possible duplicate of [Inconsistent Unicode Emoji Glyphs/Symbols](http://stackoverflow.com/questions/29659949/inconsistent-unicode-emoji-glyphs-symbols) – 一二三 Oct 03 '15 at 05:47
  • @janaspage From your question, you clearly already know the syntax for Unicode characters in HTML and JS. – 一二三 Oct 03 '15 at 23:51
  • 1
    @janaspage `︎` and `\uFE0E` are correct (2 and 8) and work fine in Safari (8 and 9), but like the answer says: browser support is spotty, and Chrome (46) is completely broken. – 一二三 Oct 04 '15 at 05:29
  • 3
    There's simply no standard way to control the rendering of Emojis. – nwellnhof Oct 07 '15 at 13:33
  • 2
    All you have to do is enforce a font that contains glyphs for this characters, and whose glyphs look the way you want (no colours, no shapes, or whatever you prefer). – ShreevatsaR May 05 '17 at 01:49
  • It's honored in Chrome 69. – Arithmomaniac Sep 27 '18 at 20:09
  • It is honored by Chrome and Edge unless the font has no glyph for the code point, which prompts these user agents to fall back to rendering the code point as the corresponding emoji. – Armen Michaeli May 22 '21 at 16:15

14 Answers14

192

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>&#xFE0E;</p>

Result: ︎

Learn more at: Unicode symbol as text or emoji

Adam Katz
  • 14,455
  • 5
  • 68
  • 83
Huang
  • 1,953
  • 1
  • 9
  • 4
  • 1
    This is super helpful, which is why I upvoted it the other day. I wonder how I can paste an emoji *and* this invisible character into a Facebook ad that I'm writing? P.S. This was also interesting: http://apple.stackexchange.com/a/240450/53510 – Ryan Mar 09 '17 at 00:15
  • 4
    I just realized that this `︎` trick doesn't work for me for certain fonts. I'm having a hard time finding a font that I can reasonably expect to be installed on all machines (Windows, iOS, Mac, Android, etc). – Ryan Mar 23 '17 at 21:50
  • 1
    This was helpful: `@font-face { font-family: "EmojiSymbols"; src: url('/fonts/EmojiSymbols-Regular.woff') format('woff'); text-decoration: none; font-style: normal; }` http://emojisymbols.com/beforeuse.php – Ryan Mar 23 '17 at 22:09
  • 20
    This solution is really not acceptable for symbols that may even occur in input fields. I'm having this trouble with the symbol ↔ used in logic, and I can't for the life of me understand why anyone thinks this should ever be an emoji! – frabjous Oct 22 '17 at 14:11
  • 1
    Beware that support for FE0F usually depends more upon the OS (rather than the browser you are using) because most browsers will internally use the native OS text renderer. It can also have different effects depending upon the glyph and the font. Also see answer https://stackoverflow.com/a/40020609/436776 – robocat Dec 17 '18 at 22:47
  • 2
    The following page is helpful for copying-and-pasting that special character immediately after an emoji to make it appear flat rather than stylized. E.g. you might see ︎ instead of and ︎ instead of and ⌛︎ instead of ⌛ and ︎ instead of (depending on your device) http://www.unicode-symbol.com/u/FE0E.html – Ryan Jan 04 '19 at 21:54
  • 38
    This renders as an emoji in the example for me, chrome 71 on mac 10.11.6. – lahwran Jan 06 '19 at 05:01
  • 1
    Here is a new related question of mine: https://apple.stackexchange.com/q/347993/53510 – Ryan Jan 08 '19 at 21:00
  • I have trouble using this. It does work with emoji you've used, as well as many others ︎ ✨︎ ︎ ⌛︎ ︎, but I can't seem to make it work with some others, like Mage: ︎. What might be the reason? – Soul Reaver Feb 08 '19 at 11:53
  • 1
    I don't think this works anymore, at least not in Chrome on Mac. The main example and all of the examples in the comments display as emoji for me in Chrome 77 and macOS 10.14.6 and I think it's been this way for a while. I really liked this little trick, too :( – dmatamales Sep 30 '19 at 07:27
  • Works on Chrome 77.0.3865.90 on Win 10 Enterprise. – Dennis T --Reinstate Monica-- Oct 24 '19 at 19:50
  • 1
    Does work inside html, but when I add ︎ in my css it just shows as regular text content: '▶︎'; – marzique Jan 10 '20 at 13:45
  • Is it possible for you to add a 2nd line showing what it should render to? For those that have browsers that don't render it. – ctrl-alt-delor Sep 01 '21 at 06:46
  • 1
    It is not working in Chrome – lepe May 09 '22 at 01:21
  • 1
    I hate when symbols like ™ are rendered as an emoji. Who had the stupid idea of making a ™ emoji?? Such a disservice. – geekley Mar 10 '23 at 05:14
  • Right now this example renders as an emoji on iPhone with Chrome. – Joooeey Apr 22 '23 at 15:00
19

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.

t_l
  • 5
  • 2
Glia
  • 371
  • 2
  • 9
  • 1
    This should be the correct answer, especially since the old invisible character method is not honored by most major browsers. – Sarah C. Corriher Aug 07 '20 at 15:40
  • It was quite strange that appending the \FE0E in CSS after an emoji the appearance depend on which symbol is used before. Example \23EA does not change in CSS with the modifier but changes in simple html. But using the 'Segoe UI Symbol' as the first font-family in the CSS helps. – Miklos Krivan Feb 01 '22 at 15:36
18

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:

<p>Normal character: ↩</p>
<p>Monospace character: <span style="font-family: monospace">↩</span></p>
cmbuckley
  • 40,217
  • 9
  • 77
  • 91
6

If your primary concern is forcing monochromatic display so the emoji don't stand out from the text too much, CSS filters, either alone or in combination with the Unicode variation selector, may be something you want.

p.gscale { 
  -webkit-filter: grayscale(100%);
  filter: grayscale(100%);
}
a {
  color: #999;
  -webkit-filter: grayscale(100%) sepia(100%) saturate(400%) hue-rotate(170deg);
   filter: grayscale(100%) sepia(100%) saturate(400%) hue-rotate(170deg);
}
<p class="gscale">You've now got emoji display on lockdown.</p>

<p>External Link: <a href="https://knowyourmeme.com/memes/party-hard">celebrate </a></p>

Unlike the variation selector, it shouldn't matter how the emoji are rendered, because CSS filters apply to everything. (I use them to grayscale PNG-format "link type" icons on hyperlinks that have been modified to point to the Wayback Machine.)

Just mind the caveat. You can't override a parent element's filter in a child, so this technique can't be used to grayscale a paragraph, then re-colorize the links within it.

...still, it's useful for situations where you're either going to be making the whole thing a hyperlink or disallowing rich markup within it. (eg. titles and descriptions)

However, this won't work unless CSS actually gets applied, so I'll give a second option which is more reliable in <title> elements than the Unicode variation selector (I'm looking at you GitHub. I don't like fake icons in my browser tabs):

If you're putting a user-provided string into a <title> element, filter out the emoji along with any bold/italic/underline/etc. markup. (Yes, for those who missed it, the standard does call for the contents of <title> to be plain text aside from the ampersand escapes and the browsers I tested all interpret tags within as literal text.)

The two ways I can think of are:

  1. Directly use a manually-maintained regex which matches the blocks where the newest version of Unicode puts its emoji and their modifiers.
  2. Iterate through the grapheme clusters and discard any which contain recognized emoji codepoints. (A grapheme cluster is a base glyph plus all the diacritics and other modifiers which make up the visible character. The example I link to uses Python's regex engine to tokenize and then the emoji package for the database, but Rust is a good example of a language where iterating grapheme clusters is quick and easy via a crate like unicode-segmentation.)
ssokolow
  • 14,938
  • 7
  • 52
  • 57
4

None of the other solutions worked for me but I eventually found something that did courtesy of css-tricks. In my use case, I was adding a link symbol at the end of each markdown header for direct linking to sections within articles but the emoji symbol looked a bit distracting. The following code allowed me to make the emoji look like a plain symbol and then switch back to looking like an emoji when hovered over which was perfect for my use case. If you just want to make the icon look more like a symbol just change the text-shadow hexadecimal color to #000 as shown in the second example.

.direct-link {
  color: transparent;
  text-shadow: 0 0 #dbe2ec;
}

.direct-link:hover {
  color: inherit;
}
<h3>Blog Subheading<a href='#' class="direct-link"></a></h3>

   .direct-link {
      color: transparent;
      text-shadow: 0 0 #000;
    }
    <h3>Blog Subheading<a href='#' class="direct-link"></a></h3>
feraleyebrows
  • 155
  • 1
  • 5
  • The phrase "none of the other" is ambiguous. We have no ideas which answers existed before you wrote this. (Yes, we can look at dates, but…) – ctrl-alt-delor Sep 01 '21 at 06:48
  • 1
    This is a cool idea, but note that many emoji have boxes around them, such as arrows and play/pause, etc. These keycap / button style emojis will become illegible with this technique. And it's always up to the font, so you have to consider different platforms. – 1j01 Feb 01 '22 at 04:22
1

Android fonts are not rich as you may expect. Font files don't have these exotic glyph and Android has a hack for few characters without glyph. They are replaced with icons.

So solution is to integrate the site with a web font (woff). Create new font file with FontForge and pick required glyph from free serif TTF for example. Every glyph takes 1k. Generate woff file.

Prepare simple CSS to import the custom font family.

style.css:

@font-face {
  font-family: 'Exotic Icons';
  src: url('exotic-icons.woff') format('woff');
}

.exotic-symbol-font {
    position: relative;
    top: 1px;
    display: inline-block;
    font-family: 'Exotic Icons';
    font-style: normal;
    font-weight: normal;
    line-height: 1;

    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

index.html file:

<html>
  <head>
    <meta charset="utf-8">
    <link href="style.css" rel="stylesheet"></head>
    <title>Test custom glyphs</title>
  </head>
  <body>
    <table>
      <tr>
        <td class="exotic-symbol-font">
             ☠ &#x2660; a  g
        </td>       
      </tr>
    </table>
  </body>
</html>
Daniil Iaitskov
  • 5,525
  • 8
  • 39
  • 49
0

Google Chrome, desktop version 75, seems to disambiguate its approach to rendering Unicode characters based on the first Unicode escape it encounters while loading a page. For instance, when parsed as the first HTML Unicode escape in a page source, and having no emoji equivalent, &#9207; seems to clarify to Chrome that the page contains escapes not to be rendered as emoji.

Clay Allen
  • 11
  • 1
0

Expanding upon ssokolow's answer, using a filter is nice and at least makes the contours visible instead of using a simple font, but converting an RGB color into a sequence of CSS filters is very hard when you want to use a specific color.

A better (although quite wordy) option is to use the <feColorMatrix> SVG filter. Combined with the grayscale filter and the data URI scheme, you can represent the color via RGB and in-line CSS:

.violet {
  color: white;
  filter: grayscale(100%) url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg'><filter id='f'><feColorMatrix type='matrix' values='0.78 0 0 0 0  0 0.082 0 0 0  0 0 0.522 0 0  0 0 0 1 0'/></filter></svg>#f");
}

Unfortunately, you cannot interpolate the URL with data (taken from attributes or variables), but at least you don't have to calculate CSS filters from RGB.

IS4
  • 11,945
  • 2
  • 47
  • 86
0

My specific version of the problem

My site is using the ◀︎ (BLACK RIGHT-POINTING TRIANGLE) and similar characters in CSS pseudo-elements (::after and ::before) to indicate the current item in a list.

In my tests, I always used the triangle character and the variation selector 15 together. First I was using both a webfont from Google Fonts and a font installed on the device that should both have contained the glyphs for those characters, but for some reason, this assumption must have been wrong. I also tried different subsets on Google Fonts, to no avail: Two of my android devices with Google Chrome and Samsung Internet (Chromium) always rendered the emoji instead of the text glyph.

My solution

My solution was to download the latest WOFF of the Gnu Free Font (which I knew to contain glyphs for those characters), include it in my project, and define it using @font-face:

@font-face {
  font-family: "Free Sans";
  src: url("/site/static/fonts/FreeFont/FreeSans.woff") format("woff");
}

Then, to set the styles for my pseudo elements:

span.current::after {
  font-family: "Free Sans", $universal-font-family ! important;
}

Discussion

I'm not yet sure about the performance impact of using that 786K extra font just for those few characters. If that becomes a problem, it should be possible to use a stripped-down custom font with just those characters instead.

Michael Jaros
  • 4,586
  • 1
  • 22
  • 39
0

If none of the other answers work for you, it's possible you have one or more of these fonts in your font stack (as was the case for us):

  • Segoe UI Emoji
  • Apple Color Emoji

These are included in a number of commonly used font stacks, like the Github font stack if I'm not mistaken.

Slbox
  • 10,957
  • 15
  • 54
  • 106
0

For new projects (>2023) maybe keep an eye out for

font-variant-emoji: text;

Which is currently (start Q3 2023) not yet supported by any browser.

-2

I dont know of a way to turn off the emoji type rendering. Usually I use an icon font such as font awesome or glyphicons (comes with Bootstrap 3).

The benefit of using these over the unicode characters is that

  1. you can choose from many different styles so it fits the design of your site;
  2. they are consistent across browsers (if you ever tried doing a unicode star character, you'll notice it's different in IE vs other browser);
  3. also, they are fully stylable, like the unicode characters you're trying to use.

The only downside is that its one more thing for the browser to download when they view your page.

Davide Pastore
  • 8,678
  • 10
  • 39
  • 53
dave.mcalpine
  • 407
  • 2
  • 7
-3

For me on OSX the solution was to set font-family to EmojiSymbols

Nathan
  • 11,938
  • 12
  • 55
  • 62
-4

None of the solutions above worked for the "Emoji for Google Chrome" Extension.

So as a workaround I made a screenshot of the Unicode Character 'BALLOT BOX WITH CHECK' (U+2611) and added it as image with php:

 $ballotBoxWithCheck='<img src="pics/U2611.png" style="height:11px;margin-bottom:-1px">'; # &#9745; or /U2611

enter image description here

See: https://spacetrace.org/man_card.php?tec_id=21&techname=multi-emp-vessel

rubo77
  • 19,527
  • 31
  • 134
  • 226
  • 2
    Almost certainly better to paste it into Inkscape using the text tool (with a font that has a suitable license selected) and then run an auto-trace, so you can get an SVG out of it that'll scale to whatever size you need. (To make it as small as possible, pair an SVG minifier with some manual editing to reduce the number of nodes in paths where the auto-trace goofed.) – ssokolow Dec 24 '19 at 08:53