How To Insert Emojis In HTML

Do you have a website and want to insert emojis in it in native HTML code? Inserting emojis is fun and easy in HTML. This article will discuss how to insert emojis into HTML in 2 different ways.

emoji mugs

Image via

Step 0. Have Your HTML Encoded in UTF-8 Encoding

This step is required for both the following 2 different ways to insert emojis into HTML code. The World Wide Web Consortium, the group that sets HTML standards, highly recommends you encode your documents as UTF-8.

Basically, to do this, at the top of your HTML file, make sure you insert something like the following:

 <meta charset='utf-8'>

Modern software like WordPress and Drupal do this by default, but if you are coding from scratch, you need to put this into your HTML File. Forcing UTF-8 encoding in your HTML file is often essential to properly render emojis. For example, the emoji for ‘kissing face with closed eyes’ ? may actually be rendered as 😚 or other gibberish without UTF-8 encoding. Having

meta charset='utf-8'

will force any browser to render your HTML code as UTF-8 encoding. This is good for at least 2 reasons:

1. It is much, much easier to maintain text where what-you-see-is-what-you-get for a webmaster. If you are going to use HTML character escapes, which I discuss below, for all non-ASCII characters, it can get pretty unmaintainable pretty quickly. You are more likely to make typos or other errors using this method.

2. If you are writing text in a non-Western European language, like Chinese, and want to use HTML character escape for every character you want to use, it can both make it a nightmare and make the code essentially unreadable for the webmaster.

Method #1. Insert The Emoji By Itself In The HTML Code

This way is certainly much easier and more modern than method number 2. Basically, for any emoji, you just paste the emoji by itself in HTML. Here is a comprehensive list of every single emoji. Find your emoji, and then copy and paste the emoji icon into your html file. Remember, your HTML code must have UTF-8 encoding explicitly declared in the head, otherwise your emoji might not be rendered properly.

Method #2. Insert The Emojis Using HTML Character Escapes

This is the older way to insert emojis, but still a useful way to insert them and possibly a more instructive way to do so. Unicode code point values exist for every Unicode value. Basically, Unicode code point values are what the creators/maintainers of Unicode use to give every Unicode character a unique representation for computers. Nearly every character from nearly every major language has a unique Unicode value. The current version of Unicode, Unicode 9.0.0, as of 2016 June 21, there are 128,172 Unicode characters. Emojis are also represented by Unicode code point values. For example, grinning face’s ? Unicode code point value is U+IF600.

To convert the Unicode code point value into an HTML character escape, you will simply do the following:

  1. Find the Unicode code point value for the emoji you want to insert. Here is a comprehensive list of all emojis in Unicode and their corresponding Unicode code point values.
  2. Once you have the relevant code point value, copy it down, and delete the “U+” part
  3. Then put an in front of the other parts of the Unicode code point value.
  4. Finally, at the end, put a ;

To convert ?’s Unicode value into an HTML character escape so that you can see a grinning face in your HTML code, simply change U+1F600 to


Now for a quick explanation of what the code means. In HTML, anything beginning with a ‘&#’ and ending with a ‘;’ (both without the quotes) indicates a special character. And the ‘x’ part of the escape code indicates to the browser that what is to follow is hex code. Unicode point values are usually represented in hex code. It is a standard.

If you use Unicode encoding, you probably won’t have to use character escapes, but in HTML there are 3 characters you must escape. &, >, and <. Below are the corresponding escape codes:
&amp for &
< for <
> for >

You must use escape codes for those 3 characters because ‘&’, ‘<‘, and ‘>’ have special meaning in HTML. This is just like data types such as int, float, etc., have special meaning in programming languages. If you don’t escape &, <, or > in HTML code, and you mean to have them displayed as you see them, then you will probably get some kind of error, or the page won’t render properly.

Additional Notes For Rendering Emojis In HTML

Save Your File In UTF-8 Encoding. Don’t Just Declare UTF-8 Encoding In The Head

Make sure that you save your HTML file in UTF-8 encoding. If you use Windows, Notepad and Wordpad may default to saving files in ASCII encoding, which we don’t want. Make sure you save the file in UTF-8 encoding otherwise non-ASCII characters, like emojis, might not render properly in the browser even if you have the header with UTF-8 encoding.

Not Every Emoji Is Supported In Browsers Yet

For example, slightly smiling face ? whose Unicode value is U+1F642 is not yet supported in native HTML in browsers (though WordPress supports it). Slightly smiling face’s emoji was introduced in 2014, but browsers yet don’t support it in native HTML. The Unicode organisation’s complete list of emojis here shows a vertical rectangle under the browser column for an emoji that is not yet support in browsers.

For a much more in depth discussion about encodings etc, I highly recommend W3’s HTML character encodings in HTML and CSS tutorial here.

Posted on Categories HTML

6 thoughts on “How To Insert Emojis In HTML”

    1. Hi. These days, method 1 is better for browsers that support modern web technology. But, for really old browsers, method 2 is good. I’d probably go with method 1. Thanks for the comment!

Leave a Reply