What are Emojis?
Emojis look like images, but they are not. They are letters (characters) from the UTF-8 (Unicode) character set, which covers almost all characters and symbols in the world. Each emoji also has an entity number, so for example the mountain emoji is 🗻 and the grinning face is 😀.
HTML Emojis Examples
HTML supports emojis in many categories, including smileys, hands, people, office, places, transport, animals, food, plants, fruits, sports, earth and sky, weather, clothing, audio and video, celebration, entertainment, and symbols.
The HTML charset Attribute
To show a page correctly, the browser must know the character set used. You set it in the <meta> tag. If you do not specify one, UTF-8 is the default in HTML.
Charset meta tag
Setting the character set to UTF-8.
<meta charset="UTF-8">
UTF-8 Characters
Many UTF-8 characters cannot be typed on a keyboard, but they can always be shown using entity numbers. For example, A is 65, B is 66, and C is 67. Start an entity number with &# and end it with a semicolon so the browser knows you are showing a character.
Example
The letters A, B, and C shown directly and by their entity numbers.
Output: complete HTML page
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<p>I will display A B C</p>
<p>I will display A B C</p>
</body>
</html>
Emoji Characters
Emojis are also characters from the UTF-8 set, so each has a number; for example, the grinning face 😄 is 128516. Because they are characters, emojis can be copied, displayed, and sized just like any other text.
A single emoji
One emoji shown by its entity number.
Output: complete HTML page
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<h1>My First Emoji</h1>
<p>😀</p>
</body>
</html>
Sized emojis
Emojis enlarged with a CSS font size.
Output: complete HTML page
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<h1>Sized Emojis</h1>
<p style="font-size:48px">
😀 😄 😍 💗
</p>
</body>
</html>