Beginner-Friendly Topic
Take your time - it's perfectly normal to re-read this topic 2-3 times. Try the interactive code editor below to run code yourself. Use the Q&A section to check your understanding before moving on.You've got this!
Lesson 4 of 5
HTML Entities & Special Characters
HTML entities are special codes that represent characters which cannot be typed directly into HTML or have special meaning in HTML syntax. For example, you cannot type < directly in your content because the browser thinks it is the start of an HTML tag. Instead, you use the entity < to display a literal less-than sign. Entities also let you display symbols like ©, ®, €, ™, arrows, emojis, and mathematical symbols. Every web developer needs to know the most common entities and when to use them.
Why HTML Entities Exist
Some characters have special meaning in HTML syntax:
- < and > are used for HTML tags. If you write <p>Use the <div> tag</p>, the browser will try to interpret <div> as an actual HTML element, breaking your page.
- & (ampersand) starts an entity reference. Writing AT&T without escaping the & can cause issues.
- " (double quote) is used in attribute values. Inside attributes, unescaped quotes break the syntax.
To display these characters as regular text, you must use HTML entities - special codes that the browser converts to the correct character.
Entities come in two formats:
1. Named entities: < > & " (human-readable)
2. Numeric entities: < > & " (character code number)
3. Hex entities: < > & (hexadecimal)
Named entities are easier to remember, but not every character has a named entity. Numeric/hex entities can represent ANY Unicode character.
Use character entities to display reserved HTML characters and special symbols
Essential HTML Entities
- < (<) - Less-than sign (<). MUST use when showing HTML tags as text.
- > (>) - Greater-than sign (>). Used to complete tag display in text.
- & (&) - Ampersand (&). MUST escape in HTML content and URLs.
- " (") - Double quote ("). Use inside attribute values.
- ' (') - Single quote/apostrophe ('). Useful inside attributes.
- ( ) - Non-breaking space. Prevents collapsing and line breaks.
- © (©) - Copyright symbol ©. Used in footers.
- ® (®) - Registered trademark ®.
- ™ (™) - Trademark symbol ™.
- € (€) - Euro sign €.
- £ (£) - British Pound £.
- ¥ (¥) - Japanese Yen ¥.
- &rupee; or ₹ - Indian Rupee ₹.
- ← → ↑ ↓ - Arrow symbols ← → ↑ ↓.
- ♥ ♣ ♠ ♦ - Card suit symbols ♥ ♣ ♠ ♦.
- ✓ (✓) - Checkmark ✓.
- × (×) - Multiplication/close × sign.
Entities Example
<!DOCTYPE html>
<html>
<body>
<h1>HTML Entities Demo</h1>
<!-- Required escaping -->
<p>To write a tag: <p>Hello</p></p>
<p>Company: AT&T</p>
<!-- Symbols -->
<p>© 2025 Priygop. All rights reserved.</p>
<p>Price: €29.99 | £24.99 | ₹2,499</p>
<p>HTML™ is ♥ by developers.</p>
<!-- Arrows -->
<p>Navigate: ← Back | Forward →</p>
<!-- Math symbols -->
<p>5 × 3 = 15 | 10 ÷ 2 = 5</p>
<p>Temperature: 30°C</p>
<!-- Non-breaking spaces for alignment -->
<p>Score: 95/100 ✓</p>
</body>
</html>Try It Yourself: HTML Entities
Quick Quiz
Key Takeaways
- HTML entities are special codes that represent characters which cannot be typed directly into HTML or have special meaning in HTML syntax.
- < (<) - Less-than sign (<). MUST use when showing HTML tags as text.
- > (>) - Greater-than sign (>). Used to complete tag display in text.
- & (&) - Ampersand (&). MUST escape in HTML content and URLs.
Finished this lesson?