How to Use Emoji in HTML
Nowadays, Emojis ๐ have become an integral part of our text communication, we use emojis to express our feelings, emotions, and reactions on different platforms like WhatsApp, Telegram, Facebook, etc.
Emojis can also add a great user experience to your website, and it can also help you to convey your message in a better way.
So, in this article, we will learn how to use emoji in HTML.
- What is Emoji?
- How to Use Emoji in HTML?
- Conclusion
Table of Contents
What is Emoji?
Emoji is a small digital image or icon used to express an idea or emotion in electronic communication.
It exists in various genres and categories including facial expressions, common objects, places, types of weather, animals, food, activities, sports, and so on.
The table below shows some categories and examples of emojis.
Category | Examples |
---|---|
Smileys | ๐ ๐ ๐ ๐ ๐ ๐ |
People | ๐จ ๐ฉ ๐ด ๐ต ๐ถ ๐ฑ ๐ฒ ๐ฎ ๐ท ๐ ๐ต๏ธโโ๏ธ |
Nature | ๐ฒ ๐ณ ๐ด ๐ต ๐ท |
Food | ๐ ๐ ๐ ๐ ๐ ๐ฑ |
Activities | โท ๐ ๐๏ธโโ๏ธ ๐๏ธ ๐คผโโ๏ธ ๐คผโโ๏ธ ๐คธโโ๏ธ ๐คธโโ๏ธ โน๏ธโโ๏ธ โน๏ธ ๐คบ ๐๏ธโโ๏ธ |
Travel | ๐ ๐ ๐ ๐ ๐ด ๐ต ๐ฒ ๐น ๐ด ๐ ๐ฉ |
How to Add Emoji in HTML
Above we have seen what is emoji and why we should use it on our website, now let's see how to add emoji in HTML.
There are 4 different ways by which you can add emojis in HTML.
- Using HTML Entities
- Using Unicode Characters
- Directly using Emoji
- Using Emoji with CSS
Let's see each of them in detail.
Using HTML Entities
HTML entities are used to represent special characters in HTML. It starts with &# or just & and ends with ;.
For example, to show the copyright symbol (ยฉ) in HTML, we can use the © or © HTML entity.
Note: Not all HTML entities have names, some of them are just numbers.
Just like that, we have HTML entities for emojis, for example, to show the smiley emoji (๐) in HTML, you can use the 😀 HTML entity.
Here are some of the HTML entities for emojis.
Emoji | HTML Entity |
---|---|
๐ | 😀 |
๐ | 😃 |
๐ | 😄 |
๐ | 😁 |
๐ฉ | 👩 |
๐ฒ | 👲 |
๐ฎ | 👮 |
๐ต๏ธโโ๏ธ | 🕵 |
๐ฒ | 🌲 |
๐ณ | 🌳 |
๐ | 🍊 |
๐ | 🍋 |
Here is an example of using HTML entities to add emojis in HTML.
Example
<p>She is happy 😀 </p>
<p>Tree grows 🌲 </p>
<p>Fruits are Juicy 🍊 </p>
Using Unicode Characters
Unicode is a standard for encoding, representing, and processing text in different languages and scripts. It is a character set that includes letters, numbers, and symbols.
Each symbol in Unicode has a unique number, called a code point. For example, the code point for the smiley emoji is U+1F600.
To use Unicode characters in HTML, you need to use the &#x before the code point.
For example, to show the smiley emoji (๐) in HTML, you can use the 😀
Unicode character.
Here is an example of using Unicode characters to add emojis in HTML.
Example
<p>She is happy 😀 </p>
<p>Tree grows 🌲 </p>
<p>Fruits are Juicy 🍊 </p>
Directly using Emoji
Emoji are supported in HTML5. You can directly copy and paste emojis in HTML without using any HTML entities or Unicode characters.
Here is an example of using emojis in HTML directly.
Using Emoji with CSS
CSS is another way to embed emoji in HTML. For this you can use the content property with the ::before and ::after pseudo-elements.
Within the content property either you can use the Unicode character or emojis directly.
Here is an example of using emoji with CSS.
Using unicode
- CSS
- HTML
.happy::before {
content: "\1F600";
}
.tree::before {
content: "\1F333";
}
.fruit::before {
content: "\1F34D";
}
<p>She is happy <span class="happy"></span> </p>
<p>Tree grows <span class="tree"></span> </p>
<p>Fruits are Juicy <span class="fruit"></span> </p>
Using emoji
- CSS
- HTML
.happy::before {
content: "๐";
}
.tree::before {
content: "๐ฒ";
}
.fruit::before {
content: "๐";
}
<p>She is happy <span class="happy"></span> </p>
<p>Tree grows <span class="tree"></span> </p>
<p>Fruits are Juicy <span class="fruit"></span> </p>
Conclusion
There are many ways to use emoji in HTML. You can use HTML entities, Unicode characters, directly use emoji or use CSS to embed emoji in HTML.
We have seen all the ways to use emoji in HTML. You can use any of the above methods to embed emoji in HTML as per your requirement.
Hope you have enjoyed learning.
Happy Coding!๐