Nearby lessons
20 of 24π€ HTML Entities
π What are HTML Entities?
HTML entities are used to represent characters that cannot be typed directly or may conflict with HTML syntax. π€
For example, '<' must be written as < so the browser doesn't confuse it with a tag.
HTML entities are codes that start with an ampersand (&) and end with a semicolon (;), used to display characters that would otherwise be interpreted as HTML syntax.
π Common HTML Entities
| Attribute | Description |
|---|---|
| Non-breaking Space |
< | Less Than |
> | Greater Than |
& | Ampersand |
" | Double Quote |
' | Single Quote |
© | Copyright Symbol |
® | Registered Trademark |
€ | Euro Symbol |
£ | Pound Symbol |
¥ | Yen Symbol |
¢ | Cent Symbol |
π§ͺ HTML Entities Example
Code Example
PREVIEW READY
β Best Practices
- β Use named entities when available for readability
- π’ Prefer numeric entities for obscure characters
- β οΈ Encode reserved characters like <, >, &, ", and ''
- π Use UTF-8 encoding when possible
- π§ͺ Test rendering across browsers
π Unicode Characters
With UTF-8 encoding, you can directly use Unicode characters in HTML. However, entities are useful for:
βοΈ Compatibility
βοΈ Clarity
βοΈ When your keyboard doesnβt support certain characters
βοΈ Compatibility
βοΈ Clarity
βοΈ When your keyboard doesnβt support certain characters
π§ Test Your Knowledge
4 QuestionsProgress: 0 / 4
Keep Going!HTML NBSP