HTML Entities

HTML Entities
1. Why HTML Entities Are Needed
Some characters have special meaning in HTML, like:
<and>→ used for tags&→ starts an entity
If you write them directly, the browser may misinterpret them.
Problem
Correct (Using Entity)
2. HTML Entity Syntax
HTML entities have two formats:
Named Entity
Numeric Entity
Both end with a semicolon (;).
3. Common Entities (Must Know)
| Character | Entity | Description |
|---|---|---|
< | < | Less than |
> | > | Greater than |
& | & | Ampersand |
" | " | Double quote |
' | ' | Single quote |
| © | © | Copyright |
| ® | ® | Registered |
| ™ | ™ | Trademark |
4. Non-Breaking Space ( )
Used to create extra spaces that won’t collapse or break lines.
- Useful for spacing
- Don’t overuse for layout (use CSS instead)
5. Currency Symbols
Example:
6. Mathematical Symbols
Example:
7. Entities for Quotes (Important for Attributes)
- Prevents attribute break
8. Emojis Using Entities
Example:
9. Displaying HTML Code as Text
To show HTML code on a webpage:
Output:
- Very useful for tutorials
Common Mistakes
- Forgetting semicolon (
;) - Using entities unnecessarily
- Using
for layout - Writing
<or&directly in text
Key Points to Remember
Entities display reserved & special characters
Always end entities with
;Use
<and>for<>Use
&for&Use CSS for spacing, not
