HTML Entities: The Complete Reference Guide
Par Salty Deprecated Software Engineer
Cet article a été généré avec l'aide de l'IA et revu par notre équipe pour en garantir l'exactitude et la qualité. Toutes les informations techniques et exemples ont été vérifiés.
If you've ever seen & in a webpage's source code and wondered what it means, you've encountered an HTML entity. HTML entities are special codes that represent characters which would otherwise be interpreted as HTML markup— or characters that don't exist on a standard keyboard.
This guide covers what they are, why they exist, the most common ones you'll use, and how to handle them in modern frameworks like React.
Why HTML Entities Exist
HTML uses certain characters as part of its syntax. The angle brackets < and > define tags. The ampersand & starts entity references. Quotes delimit attribute values.
So what happens when you want to display these characters in your content? If you write <div> in your HTML, the browser thinks you're opening a div tag. To show the literal text on the page, you need entities.
To display this:
<div class="example">
You write this in HTML:
<div class="example">
The 5 Essential HTML Entities
These are the entities you'll use 90% of the time. Memorize them:
| Character | Entity Name | Entity Number | Description |
|---|---|---|---|
| & | & | & | Ampersand |
| < | < | < | Less than |
| > | > | > | Greater than |
| " | " | " | Double quote |
| ' | ' | ' | Single quote / apostrophe |
Common Special Characters
Beyond the essential five, here are the entities you'll reach for most often:
| Character | Entity | Description |
|---|---|---|
| | Non-breaking space | |
| © | © | Copyright |
| ® | ® | Registered trademark |
| ™ | ™ | Trademark |
| — | — | Em dash |
| – | – | En dash |
| • | • | Bullet point |
| … | … | Horizontal ellipsis |
| ¢ £ € ¥ | ¢ £ € ¥ | Currency symbols |
Math & Technical Symbols
| Character | Entity | Description |
|---|---|---|
| × | × | Multiplication sign |
| ÷ | ÷ | Division sign |
| ≠ | ≠ | Not equal |
| ≤ ≥ | ≤ ≥ | Less/greater than or equal |
| ∞ | ∞ | Infinity |
| ← → ↑ ↓ | ← → ↑ ↓ | Arrows |
Numeric Character References
Every character in Unicode can be represented as a numeric entity using its code point:
Decimal format:
© → © (copyright)
€ → € (euro sign)
Hexadecimal format:
© → © (copyright)
€ → € (euro sign)
In 2026, most browsers handle UTF-8 natively. You can often type special characters directly in your HTML source instead of using entities — as long as your file is saved as UTF-8. Entities are still required for &, <, >, and " in HTML context.
HTML Entities in React / JSX
React/JSX handles entities a bit differently than plain HTML. Here's what works and what doesn't:
// Named entities work in JSX text content:
<p>Copyright © 2026</p>
// Unicode escape sequences in JS expressions:
<p>{"©"} 2026</p>
// Use ' for apostrophes in JSX:
<p>It's working</p>
In JSX text content (between tags), named HTML entities like © work fine. Inside JavaScript expressions (curly braces), use Unicode escape sequences (\u00A9) or the actual character instead.
Security: Why Entities Matter for XSS Prevention
HTML entities aren't just about displaying special characters — they're a critical part of preventing Cross-Site Scripting (XSS) attacks. If user input is rendered as HTML without escaping, an attacker could inject malicious scripts.
Modern frameworks like React automatically escape JSX expressions, but if you render raw HTML strings, you must encode entities manually. Our HTML Entity Encoder makes it easy to encode and decode strings safely.
Quick Encoding/Decoding
Need to quickly encode or decode HTML entities? Here are your options:
JavaScript (encode):
const encoded = text
.replace(/&/g, "&")
.replace(/</g, "<")
.replace(/>/g, ">")
.replace(/"/g, """)
.replace(/'/g, "'");
Or skip the code and use our free HTML Entity Encoder/Decoder — paste your text, get the encoded output instantly.
Want to learn more web fundamentals? Read CSS Tricks AI Generates But Can't Explain, try our HTML Entity Encoder, or browse all our free developer tools.
Écrit sous le nom de plume éditorial de The IT Hustle : plus de 25 ans comme technicien laptop, administrateur système, ingénieur stockage et ingénieur logiciel, aujourd’hui aux commandes d’agents IA. Chaque article est relu par un humain avant publication ; voir la charte éditoriale.
Reste dans la boucle
Sois le premier informé des nouveaux outils, articles et mises à jour. Sans spam.
Générez vos propres prompts anti-hallucination
Notre AI Prompt Engine utilise une technologie propriétaire pour générer des prompts avec vérification intégrée et tests de contradiction.
Essayer 3 générations gratuites →