Emoji are small graphical images that are used to represent emotions, objects, and ideas. They can be inserted into HTML documents by using character code. For example,
<p>😀</p>
Browser Output
Here, 😀
is the character code for the above emoji.
Ways To Insert Emojis In Html
There are three ways to insert emojis into an HTML document. They are:
- Hexadecimal code
- Decimal code
- Copy and paste from external sources
We will learn about each of them in detail.
Hexadecimal code
We can add emojis to an HTML document by using their hexadecimal code. These code starts with &#x
and ends with ;
to specify browser that these are hexadecimal codes. For example,
<p>HTML is <span>💙</span> </p>
Browser Output
Here, 💙
is the hex code for the blue heart emoji.
Note: Hexadecimal code provides portability and consistency to the document in the long run.
Decimal Code
We can add Emojis to an HTML document by using their decimal code within the required tag. These codes start with &# and end with an ; to inform the browser that the character represented by the decimal code has been displayed. For example,
<p>😀</p>
Browser Output
Here, 😀
is the decimal character code for the smiling emoji.
Copy and paste from external sources
We can add emojis in an HTML document by copying it from some external sources and pasting it into code. For example,
<p>HTML is <span> 💜 </span> </p>
Browser Output
Here, we have copied the purple heart emoji somewhere from the internet and pasted it to our HTML file.
Some Popular Emojis
Emoji | Name | Code |
---|---|---|
😂 |
Face with Tears of Joy | 😂 |
❤ |
Black Heart | ❤ |
😍 |
Smiling Face with Heart-Shaped Eyes | 😍 |
🙏 |
Person with Hands Folded | 🙏 |
🤣 |
Rolling On The Floor Laughing | 🤣 |
💕 |
Two Hearts | 💕 |
😭 |
Loudly Crying Face | 😭 |
🔥 |
Fire | 🔥 |
😘 |
Face Throwing a Kiss | 😘 |
👍 |
Thumbs Up | 👍 |