HTML Entities
What are HTML Entities?
HTML entities are special characters used to display characters that have special meaning in HTML or characters that cannot be typed on a keyboard. They're written as &entity_name; or &#entity_number;. HTML entities are essential for displaying reserved characters correctly.
Why Use HTML Entities?
HTML entities are used for:
- Reserved characters: Characters with special meaning in HTML (like < and >)
- Special characters: Characters that cannot be typed on a keyboard
- Consistent display: Ensure characters display correctly across browsers
- Accessibility: Screen readers can better interpret special characters
Common HTML Entities
Here are the most commonly used HTML entities:
Reserved Characters
Characters with special meaning in HTML must be escaped:
Example
<p>Use <div> for containers.</p>
<p>The price is < $10 & > $5.</p>
<p>Use "quotes" for text.</p>
Common Reserved Character Entities
| Character | Entity Name | Entity Number | Description |
|---|---|---|---|
< |
< |
< |
Less than |
> |
> |
> |
Greater than |
& |
& |
& |
Ampersand |
" |
" |
" |
Double quote |
' |
' |
' |
Single quote (apostrophe) |
Special Character Entities
Common special characters and symbols:
| Character | Entity Name | Entity Number | Description |
|---|---|---|---|
|
|
  |
Non-breaking space |
© |
© |
© |
Copyright symbol |
® |
® |
® |
Registered trademark |
™ |
™ |
™ |
Trademark symbol |
€ |
€ |
€ |
Euro symbol |
£ |
£ |
£ |
Pound symbol |
¥ |
¥ |
¥ |
Yen symbol |
Using HTML Entities
Example
<p>Copyright © 2025 My Website</p>
<p>Price: £10 & €12</p>
<p>HTML uses <tags> for markup.</p>
<p>Use "quotes" in attributes.</p>
Entity Name vs. Entity Number
You can use either entity names or entity numbers. Entity names are easier to remember, but entity numbers work in all browsers:
Example - Entity Name
<p>Copyright © 2025</p>
Example - Entity Number
<p>Copyright © 2025</p>
Non-Breaking Space
The non-breaking space entity ( ) prevents line breaks between words:
Example
<p>Mr. John Doe</p>
<p>5 miles</p>
<p>January 15, 2025</p>
Best Practices
- Always escape reserved characters: Use entities for <, >, &, ", '
- Use entity names when possible: Easier to read and remember
- Use entity numbers as fallback: Entity numbers work in all browsers
- Don't overuse : Use CSS for spacing instead
- Test display: Ensure entities display correctly across browsers