HTML Entities
HTML entities are special codes used to display reserved characters and symbols that have special meaning in HTML or cannot be easily typed on a keyboard.
Why Use HTML Entities?
Some characters are reserved in HTML and need to be represented as entities:
<!-- Wrong: Browser interprets < as start of tag -->
<p>Use the <div> tag</p>
<!-- Correct: Use entity -->
<p>Use the <div> tag</p>
Entity Syntax
HTML entities can be written in two ways:
<!-- Named entity -->
&entity_name;
<!-- Numeric entity -->
&#entity_number;
Reserved Characters
These characters have special meaning in HTML:
< <!-- < (less than) -->
> <!-- > (greater than) -->
& <!-- & (ampersand) -->
" <!-- " (double quote) -->
' <!-- ' (apostrophe) -->
Example
<p>To create a paragraph, use <p> tags.</p>
<p>The & symbol is called an ampersand.</p>
<p>She said, "Hello!"</p>
Common Symbols
Copyright and Trademarks
© <!-- © (copyright) -->
® <!-- ® (registered trademark) -->
™ <!-- ™ (trademark) -->
<p>© 2024 My Company®</p>
<p>Product Name™</p>
Currency Symbols
$ <!-- $ (dollar) -->
€ <!-- € (euro) -->
£ <!-- £ (pound) -->
¥ <!-- ¥ (yen) -->
¢ <!-- ¢ (cent) -->
<p>Price: $99.99</p>
<p>Price: €85.50</p>
<p>Price: £75.00</p>
Mathematical Symbols
× <!-- × (multiplication) -->
÷ <!-- ÷ (division) -->
− <!-- − (minus) -->
± <!-- ± (plus-minus) -->
≠ <!-- ≠ (not equal) -->
≤ <!-- ≤ (less than or equal) -->
≥ <!-- ≥ (greater than or equal) -->
° <!-- ° (degree) -->
¼ <!-- ¼ (one quarter) -->
½ <!-- ½ (one half) -->
¾ <!-- ¾ (three quarters) -->
<p>5 × 3 = 15</p>
<p>10 ÷ 2 = 5</p>
<p>Temperature: 25°C</p>
<p>Recipe: ½ cup of sugar</p>
Spacing Entities
<!-- Non-breaking space -->
  <!-- En space (half em) -->
  <!-- Em space (full em) -->
<p>First Second</p>
<p>Multiple spaces here</p>
Arrows and Symbols
← <!-- ← (left arrow) -->
→ <!-- → (right arrow) -->
↑ <!-- ↑ (up arrow) -->
↓ <!-- ↓ (down arrow) -->
↔ <!-- ↔ (left-right arrow) -->
♠ <!-- ♠ (spade) -->
♣ <!-- ♣ (club) -->
♥ <!-- ♥ (heart) -->
♦ <!-- ♦ (diamond) -->
<p>Navigate: ← Previous | Next →</p>
<p>Scroll ↑ to top</p>
<p>Card suits: ♠ ♣ ♥ ♦</p>
Accented Characters
á <!-- á -->
é <!-- é -->
í <!-- í -->
ó <!-- ó -->
ú <!-- ú -->
ñ <!-- ñ -->
Á <!-- Á -->
É <!-- É -->
<p>Café</p>
<p>España</p>
<p>Résumé</p>
Numeric Entities
You can also use numeric codes:
<!-- Decimal -->
© <!-- © -->
€ <!-- € -->
<!-- Hexadecimal -->
© <!-- © -->
€ <!-- € -->
Complete Example
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>HTML Entities Demo</title>
<style>
body {
font-family: Arial, sans-serif;
padding: 20px;
max-width: 800px;
margin: 0 auto;
}
.section {
background-color: #f5f5f5;
padding: 15px;
margin: 15px 0;
border-radius: 5px;
}
code {
background-color: #e0e0e0;
padding: 2px 5px;
border-radius: 3px;
}
</style>
</head>
<body>
<h1>HTML Entities Reference</h1>
<div class="section">
<h2>Reserved Characters</h2>
<p>To display <div> tags, use entities.</p>
<p>The & symbol must be escaped.</p>
</div>
<div class="section">
<h2>Copyright & Legal</h2>
<p>© 2024 Company Name®</p>
<p>Product™ is our trademark.</p>
</div>
<div class="section">
<h2>Pricing</h2>
<p>Standard: $29.99</p>
<p>Premium: €49.99</p>
<p>Enterprise: £99.99</p>
</div>
<div class="section">
<h2>Mathematics</h2>
<p>5 × 3 = 15</p>
<p>20 ÷ 4 = 5</p>
<p>Temperature: 72°F</p>
<p>Recipe: ¾ cup flour</p>
</div>
<div class="section">
<h2>Navigation</h2>
<p>← Previous | Next →</p>
<p>Scroll ↑ to top | ↓ to bottom</p>
</div>
<div class="section">
<h2>International</h2>
<p>Café in España</p>
<p>Résumé required</p>
</div>
</body>
</html>
Practice Exercise
Related Video Tutorials
Congratulations on completing the HTML section! Here are some curated video tutorials to reinforce your learning:
HTML Full Course - Build a Website Tutorial
Complete HTML tutorial for beginners covering all essential HTML elements and concepts
Video will load when visible
HTML Crash Course For Absolute Beginners
Quick crash course covering HTML fundamentals and basic webpage structure
Video will load when visible
Learn HTML - Full Tutorial for Beginners
Comprehensive HTML tutorial with hands-on examples and projects
Video will load when visible