HTML Entities & Symbols
HTML entities are special codes used to display reserved characters, symbols, or invisible spaces in a webpage. They are essential because some characters, like <
or >
, have a special meaning in HTML and cannot be used directly.
Why Use HTML Entities:
- Display Reserved Characters: Some characters are reserved in HTML (like
<
,>
,&
) and need to be written as entities to appear correctly. - Add Special Symbols: Entities allow you to include symbols like ©, ®, ™, arrows, fractions, or accented letters.
- Maintain Proper Formatting: Non-breaking spaces (
) help control spacing without breaking lines.
Common HTML Entities:
Entity | Symbol | Description |
---|---|---|
< | < | Less-than symbol |
> | > | Greater-than symbol |
& | & | Ampersand |
| (space) | Non-breaking space |
© | © | Copyright symbol |
® | ® | Registered trademark |
™ | ™ | Trademark |
" | " | Double quotation mark |
' | ' | Single quotation mark |
Example:
<p>5 < 10 & 10 > 5</p>
<p>© 2025 My Website</p>
Output:
Emojis in HTML (UTF-8)
HTML supports emojis using Unicode (UTF-8) encoding. Emojis can be added in two main ways:
- Directly typing the emoji in your HTML content (if your file uses UTF-8 encoding).
- Using Unicode numeric codes with
&#code;
or hexadecimal codes withode;
.
Example:
<p>I ❤️ HTML 😃</p>
<p>Smile: 😀</p>
<p>Thumbs up: 👍</p>
Output :
Tips for Using Emojis in HTML:
- Ensure your HTML file has UTF-8 encoding
<meta charset="UTF-8">
- Use Unicode codes when you want consistent rendering across browsers and platforms.
- Emojis can enhance user engagement, highlight important points, or add a friendly touch to content.