In HTML, certain characters are reserved because they have special structural meaning in HTML markup. For instance, if you type the less-than sign (<) or greater-than sign (>) directly into plain text, the web browser interprets them as opening or closing HTML tags. To display reserved characters safely, or to render typographic symbols that do not exist on a standard keyboard (like ©, €, £, ™), HTML provides Character Entities.
A character entity can be written in two standard formats:
&), followed by a mnemonic name, and ends with a semicolon (;). Example: < displays <. (Easy to remember).&#), followed by the decimal character code, and ends with a semicolon. Example: < displays <. (Universally supported across all XML/HTML parsers).&#x followed by the hex code. Example: < displays <.These five characters must always be replaced with character entities whenever used inside regular body text or attribute values:
| Character | Description | Entity Name | Entity Number (Dec) | Entity Number (Hex) |
|---|---|---|---|---|
| < | Less-than sign | < |
< |
< |
| > | Greater-than sign | > |
> |
> |
| & | Ampersand | & |
& |
& |
| " | Double quotation mark | " |
" |
" |
| ' | Single quotation mark (apostrophe) | ' |
' |
' |
In HTML, browsers automatically collapse consecutive whitespace characters (multiple spaces, tabs, and newlines) into a single space. If you want to force multiple consecutive spaces, you must use the non-breaking space entity: .
Crucial Word-Wrapping Function: A non-breaking space also prevents the browser from breaking a line between two linked terms. For example, writing 10 MB or Section 4 guarantees the number and its unit will never be split across two separate lines.
| Symbol | Description | Entity Name | Entity Number |
|---|---|---|---|
| © | Copyright | © |
© |
| ® | Registered Trademark | ® |
® |
| ™ | Trademark | ™ |
™ |
| € | Euro Currency | € |
€ |
| ₹ | Indian Rupee Symbol | — | ₹ |
| £ | British Pound | £ |
£ |
| ¥ | Japanese Yen | ¥ |
¥ |
| ¢ | Cent | ¢ |
¢ |
| — | Em Dash (Long Dash) | — |
— |
| • | Bullet Symbol | • |
• |
For bloggers and software engineers, understanding entity encoding is vital for security. If a user submits a malicious comment containing <script>stealCookies()</script>, storing and re-rendering that raw string in HTML executes the attacker's script (a Cross-Site Scripting / XSS vulnerability). By escaping and converting < into < and > into >, the browser safely prints the literal text without executing it.
Assignment Scenario: Create a commercial website footer component incorporating copyright symbols, trade marks, non-breaking spaces for financial currency guarantees, and mathematical pricing calculations.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>HTML Entities Practice</title>
<style>
.footer-box {
background-color: #2c3e50;
color: #ecf0f1;
padding: 24px;
font-family: Arial, sans-serif;
border-radius: 6px;
max-width: 650px;
margin: 20px auto;
line-height: 1.8;
}
.price-tag {
color: #2ecc71;
font-weight: bold;
}
</style>
</head>
<body>
<div class="footer-box">
<h3 style="margin-top: 0; color: #f1c40f;">Veewom Technologies™ Learning Portal</h3>
<p>
Annual Web Development Certification • Special Student Offer:
<span class="price-tag">₹ 1,999</span>
(Normally € 49 or $ 55).
</p>
<p>
<em>Formula:</em> Passing Score ≥ 75% & Lab Attendance > 80%.
</p>
<hr style="border-color: #4a6278;">
<p style="font-size: 13px; color: #bdc3c7; margin: 0;">
© 2016–2026 Veewom.com®. All Rights Reserved.
Unauthorized copying of tutorial materials is strictly prohibited by law.
</p>
</div>
</body>
</html>
<, >, and &) that the browser would otherwise interpret as HTML tags, or to display invisible characters (like non-breaking spaces) and symbols absent from a physical keyboard.
©), which is intuitive and easy to remember, but older browsers may lack definitions for rare symbols. An entity number references the character's exact Unicode decimal/hex code (e.g., ©), ensuring 100% universal rendering across all XML, SGML, and web browser parsers.
<script> to <script>), the browser treats the characters strictly as printable strings rather than executable JavaScript instructions, defusing the attack.
₹ or hexadecimal ₹.
© instead of ©) violates HTML syntax standards. While some modern browsers may guess the entity in simple contexts, XML parsers and strict validators will reject the document or display the raw characters.
<meta charset="UTF-8">, you can directly paste symbols like ©, €, and ₹ directly into your HTML file. However, reserved characters (<, >, &, ") MUST still use character entities regardless of character encoding.
&lt;. The browser parses & into a literal & and prints the remaining lt; as text.