HTML entities are special code sequences that display reserved characters (like < and >), invisible spaces, symbols, and non-ASCII characters without triggering HTML tag parsing errors.
HTML entities begin with an ampersand (&) and end with a semicolon (;). They can be declared using entity names or numerical codes:
<!-- Display reserved HTML tag characters -->
<p><div> represents a block container.</div></p>
<!-- Reserved and special character examples -->
<p>Copyright © 2026 | All rights reserved ®</p>
<!-- Non-breaking space entity -->
<p>Word1 Word2</p>
Common HTML entity reference table:
< (<): Less-than symbol (prevents tag parsing).> (>): Greater-than symbol.& (&): Ampersand symbol." ("): Quotation mark. : Non-breaking space (prevents text automatic line breaks).© (©): Copyright symbol.™ (™): Trademark symbol.flowchart LR
A["Raw HTML Source (<p>)"] --> B["Browser HTML Parser"]
B --> C["Renders Entity Symbol (<p>) On Screen"]
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>HTML Entities Demonstration</title>
</head>
<body style="font-family: system-ui, sans-serif; background-color: #0f172a; color: #f8fafc; padding: 2rem;">
<h2>Special Character Entities Showcase</h2>
<div style="background-color: #1e293b; padding: 1.5rem; border-radius: 8px; max-width: 500px;">
<p>Price: $99 & Shipping is "FREE"!</p>
<p>Formula: 5 < 10 && 20 > 15</p>
<p>Brand Notice: KoderSolution™ © 2026</p>
</div>
</body>
</html>
& instead of raw & in text URLs and markup: Raw ampersands can confuse HTML entity parsers inside HTML attributes. sparingly: Avoid using multiple entity chains to create layout spacing; use CSS margins or padding instead.< and > in inline code snippets: Ensures browser renders code samples visually rather than attempting to parse missing HTML tags.Write an HTML paragraph displaying the sentence: To write a comment, use <!-- comment --> using < and > entities!
Sign in to track your learning journey, earn industry-recognized certificates, and join our elite developer community.
Quick Access With
Experiment with the code from this lesson in our interactive playground.
You've completed this section! Take a quick 5-question quiz to check your understanding.