HTML Entities
Sometimes in HTML, you want to show a special character—like a <
, >
, or &
—but if you write them directly, the browser might misunderstand them as HTML code.
That’s where HTML Entities come in! They allow you to display reserved symbols, invisible characters, or special signs.
Let’s understand this in a practical and beginner-friendly way 👇
❓ Why Use HTML Entities?
Some characters are reserved in HTML. For example:
<
is used to start a tag>
ends a tag&
is used for entities themselves
If you want to display these characters literally, you need to use their HTML entity code.
🧩 Common HTML Entities
Character | Entity Name | Code |
---|---|---|
< | < | < |
> | > | > |
& | & | & |
" | " | " |
' | ' (HTML5 only) | ' |
© | © | © |
® | ® | ® |
₹ | ₹ | No named entity |
→ | → | → |
← | ← | ← |
🕳️ Non-Breaking Space:
If you need to add extra space that won’t break onto a new line, use:
<p>Hello World!</p>
- Useful when aligning text or avoiding line breaks
- Note: Overusing it for layout is not recommended (use CSS instead)
🧪 Try This in Your HTML
<p>5 < 10 and 10 > 5 is always true.</p>
<p>Use & to connect two values like "A & B".</p>
<p>He said, "HTML is fun!"</p>
<p>This product costs ₹999.</p>
<p>Move forward → or back ←.</p>
<p>Copyright © 2025 W3Buddy</p>
<p>Keep some space: Here it is.</p>
💡 Where to Use HTML Entities
- When displaying code or reserved characters
- In user-facing text that includes symbols
- When writing quotes inside attributes
- For international characters or currency
⚠️ Bonus Tip:
You can also use numeric entities (like ©
) for full browser support. Named entities are more readable, though!
🔁 Quick Recap
Entity | Shows | Used When… |
---|---|---|
< | < | Displaying less-than symbol |
> | > | Displaying greater-than symbol |
& | & | Displaying ampersand |
" | " | Displaying double quotes |
| Space | Adding non-breaking space |
₹ | ₹ | Showing currency symbol (Rupee) |
👉 Coming Up Next:
Now that we’ve covered text formatting and special characters, we’ll move into HTML Lists – ordered, unordered, and description lists.
📚 Next: HTML Lists (Ordered, Unordered, and Description)