Skip to main content

Advanced HTML

HTML Emojis

Written by Updated HTML Emojis exercises

Emojis are just characters, like letters. You can type or paste πŸ˜€ straight into your HTML, or write it as a code like 😀. Either way, the browser draws it with the device's emoji font, which is why the same emoji looks different on an iPhone and on Windows.

Each emoji has a number in the Unicode standard. πŸ˜€ is number 128512, which is 1F600 in hexadecimal. HTML lets you write that number as an entity.

Syntax

The same emoji, three ways

html

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Emoji codes</title>
</head>
<body>
  <p>Typed directly: πŸ˜€</p>
  <p>Hex code: &#x1F600;</p>
  <p>Decimal code: &#128512;</p>
</body>
</html>

All three lines show the same grinning face. The hex version starts with &#x, the decimal version with just &#, and both end with ;.

Typing emojis directly

html

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>HTML Emojis</title>
</head>
<body>
  <h2>Using Emojis in HTML</h2>
  <p>I love HTML 😍 and CSS 🎨!</p>
  <p>Learning is fun πŸš€βœ¨</p>
</body>
</html>

This is the simplest way and works everywhere, as long as the page has <meta charset="UTF-8">. Without it, emojis can turn into strange characters like "Γ°ΕΈΛœβ‚¬". On Windows, press Windows + . to open the emoji picker; on a Mac, Ctrl + Cmd + Space.

Common emoji codes

EmojiNameEntity numberHex entity
πŸ˜€Grinning face&#128512;&#x1F600;
πŸ˜‚Face with tears of joy&#128514;&#x1F602;
😍Heart eyes&#128525;&#x1F60D;
😎Cool face&#128526;&#x1F60E;
😒Crying face&#128546;&#x1F622;
❀️Red heart&#10084;&#x2764;
⭐Star&#11088;&#x2B50;
πŸ”₯Fire&#128293;&#x1F525;
πŸš€Rocket&#128640;&#x1F680;
βœ…Check mark&#9989;&#x2705;
πŸ’‘Light bulb&#128161;&#x1F4A1;

Emoji size

html

<p style="font-size: 24px; font-family: 'Segoe UI Emoji';">
  HTML makes me πŸ˜ƒ and CSS makes me 🎨
</p>

Emojis grow with font-size, like any text. Setting a font family such as Segoe UI Emoji only changes anything on Windows; other systems use their own emoji fonts.

Good to know

  • Screen readers read emojis out by name, like "rocket". Three rockets in a row are read three times, so use them sparingly.
  • Do not use an emoji alone as a button label. Add text, or an aria-label.
  • Some emojis are made of several characters joined together, such as skin tones and family emojis, so one emoji can count as several characters in JavaScript.
  • For other symbols like Β© and β†’, see HTML Entities & Symbols.

Browser Support

Chrome
Edge
Firefox
Safari
Opera
IE9+
YesYesYesYesYesYes

HTML Emojis exercises

Show an emoji

Write a paragraph that says To the moon πŸš€

Result

Check your answer to see it here.