ENTITIES7 min20 XP

HTML Entities

Learn HTML Entities with live examples, interactive editor, and Shiv AI code review.

HTML Entities

HTML entities let you display characters that would otherwise break HTML parsing or that are not available on your keyboard. They start with & and end with ;.

Why Entities Exist

Example 1 — The Problem and the Solution
<!-- PROBLEM: This breaks HTML -->
<p>5 < 10 and 10 > 5</p>
<!-- Browser sees <10 as a tag! -->

<!-- SOLUTION: Use entities -->
<p>5 &lt; 10 and 10 &gt; 5</p>
<!-- Renders as: 5 < 10 and 10 > 5 -->

<!-- Copyright and brand symbols -->
<p>&copy; 2026 CIWeb &mdash; All rights reserved.</p>
<p>Price: &rupees; 99 &mdash; Buy Now!</p>

5 < 10 and 10 > 5

© 2026 CIWeb — All rights reserved.

Price: ₹ 99 — Buy Now!

The browser renders &lt; as < and &gt; as >. They are safe HTML representations of characters that would otherwise confuse the parser.

Essential Entities Reference

Example 2 — Most Used Entities
<p>&lt;    < (less-than, safe for HTML)</p>
<p>&gt;    > (greater-than)</p>
<p>&amp;   & (ampersand, use in HTML!)</p>
<p>&quot;  " (double quote)</p>
<p>&apos;  ' (apostrophe)</p>
<p>&nbsp;  non-breaking space</p>
<p>&copy;  © copyright symbol</p>
<p>&reg;   ® registered trademark</p>
<p>&trade; ™ trademark</p>
<p>&mdash; — em dash</p>
<p>&ndash; – en dash</p>
<p>&#8377; ₹ Indian Rupee sign</p>
<p>&#128640;🚀 Rocket emoji</p>
< > & " '
    (non-breaking spaces)
© CIWeb 2026
® Registered
™ Trademark
Price — ₹299
2024–2026
🚀 Rocket
You can also use numeric codes: &#8377; = ₹. Any Unicode character can be written as &#NNNN; where NNNN is the Unicode code point.
When to Use Entities
&amp;Use instead of & in HTML text. Required in URLs inside href attributes too.
&lt; &gt;Required when writing HTML code examples in HTML, or comparison operators in text.
&nbsp;Non-breaking space: two words joined by &nbsp; will never break across lines. Use for units: 50&nbsp;km.
&copy;Copyright in footer. Looks professional. Exactly the same as typing © if your file is UTF-8.
Modern HTML is UTF-8

With <meta charset="UTF-8"> you can type or paste any character directly — Hindi text, emojis, ©, ₹, → — without entities. Entities are mainly needed for <, >, and & which have special meaning in HTML. Everything else can be typed directly in UTF-8 files.

Why &amp; is the Special One

The & character starts every entity. If you write an & in HTML without a valid entity following it, browsers try to parse it as the start of an entity and may display garbled text. Always write &amp; when you mean a literal ampersand — for example in URLs, song titles like "Faith & Courage", or company names like "H&M".

CIWeb HTML Course • 22 Lessons • Free

Explain with Analogies

Shiv AI explains this lesson using real-life analogies — no code, just clear examples.

Click the Explain tab to generate analogies.
index.html
Live Preview
Write code then click Deep Analyze

Which entity must you use to display the & character in HTML?

Explanation&amp;amp; is the entity for the ampersand &amp; character. Since &amp; starts all entities in HTML, you must escape it as &amp;amp; when you want to display a literal ampersand. Writing raw &amp; in HTML text may cause parsing issues.
Build Challenge
Entities Page
Build a page using at least 5 different HTML entities: &amp;lt;, &amp;gt;, &amp;amp;, &amp;copy;, &amp;mdash;, and the rupee symbol.
Requirements (5 to pass)
lt and gt
amp entity
copy
mdash or ndash
rupee or other numeric
solution.html
Preview
Community Wall
Lesson 14
0/500
0/20 lines
as
Recent Posts
Lesson 14
AI
Shiv AI
Online