Skip to main content

Beginner-Friendly Topic

Take your time - it's perfectly normal to re-read this topic 2-3 times. Try the interactive code editor below to run code yourself. Use the Q&A section to check your understanding before moving on.You've got this!

Lesson 4 of 5

HTML Entities & Special Characters

HTML entities are special codes that represent characters which cannot be typed directly into HTML or have special meaning in HTML syntax. For example, you cannot type < directly in your content because the browser thinks it is the start of an HTML tag. Instead, you use the entity &lt; to display a literal less-than sign. Entities also let you display symbols like ©, ®, €, ™, arrows, emojis, and mathematical symbols. Every web developer needs to know the most common entities and when to use them.

15 minBy Priygop Editorial TeamUpdated 2026Peer Reviewed & Verified

Why HTML Entities Exist

Some characters have special meaning in HTML syntax:

  • < and > are used for HTML tags. If you write <p>Use the <div> tag</p>, the browser will try to interpret <div> as an actual HTML element, breaking your page.
  • & (ampersand) starts an entity reference. Writing AT&T without escaping the & can cause issues.
  • " (double quote) is used in attribute values. Inside attributes, unescaped quotes break the syntax.

To display these characters as regular text, you must use HTML entities - special codes that the browser converts to the correct character.

Entities come in two formats:
1. Named entities: &lt; &gt; &amp; &quot; &nbsp; (human-readable)
2. Numeric entities: &#60; &#62; &#38; &#34; (character code number)
3. Hex entities: &#x3C; &#x3E; &#x26; (hexadecimal)

Named entities are easier to remember, but not every character has a named entity. Numeric/hex entities can represent ANY Unicode character.

Diagram
Loading diagram…

Use character entities to display reserved HTML characters and special symbols

Essential HTML Entities

  • &lt; (&#60;) - Less-than sign (<). MUST use when showing HTML tags as text.
  • &gt; (&#62;) - Greater-than sign (>). Used to complete tag display in text.
  • &amp; (&#38;) - Ampersand (&). MUST escape in HTML content and URLs.
  • &quot; (&#34;) - Double quote ("). Use inside attribute values.
  • &apos; (&#39;) - Single quote/apostrophe ('). Useful inside attributes.
  • &nbsp; (&#160;) - Non-breaking space. Prevents collapsing and line breaks.
  • &copy; (&#169;) - Copyright symbol ©. Used in footers.
  • &reg; (&#174;) - Registered trademark ®.
  • &trade; (&#8482;) - Trademark symbol ™.
  • &euro; (&#8364;) - Euro sign €.
  • &pound; (&#163;) - British Pound £.
  • &yen; (&#165;) - Japanese Yen ¥.
  • &rupee; or &#8377; - Indian Rupee ₹.
  • &larr; &rarr; &uarr; &darr; - Arrow symbols ← → ↑ ↓.
  • &hearts; &clubs; &spades; &diams; - Card suit symbols ♥ ♣ ♠ ♦.
  • &check; (&#10003;) - Checkmark ✓.
  • &times; (&#215;) - Multiplication/close × sign.

Entities Example

Entities Example
<!DOCTYPE html>
<html>
<body>
  <h1>HTML Entities Demo</h1>
  
  <!-- Required escaping -->
  <p>To write a tag: &lt;p&gt;Hello&lt;/p&gt;</p>
  <p>Company: AT&amp;T</p>
  
  <!-- Symbols -->
  <p>&copy; 2025 Priygop. All rights reserved.</p>
  <p>Price: &euro;29.99 | &pound;24.99 | &#8377;2,499</p>
  <p>HTML&trade; is &hearts; by developers.</p>
  
  <!-- Arrows -->
  <p>Navigate: &larr; Back | Forward &rarr;</p>
  
  <!-- Math symbols -->
  <p>5 &times; 3 = 15 | 10 &divide; 2 = 5</p>
  <p>Temperature: 30&deg;C</p>
  
  <!-- Non-breaking spaces for alignment -->
  <p>Score:&nbsp;&nbsp;&nbsp;95/100 &check;</p>
</body>
</html>

Try It Yourself: HTML Entities

Try It Yourself: HTML EntitiesHTML
HTML
✓ Valid
HTML|14 lines|✓ Valid syntax
UTF-8

Quick Quiz

Key Takeaways

  • HTML entities are special codes that represent characters which cannot be typed directly into HTML or have special meaning in HTML syntax.
  • &lt; (&#60;) - Less-than sign (<). MUST use when showing HTML tags as text.
  • &gt; (&#62;) - Greater-than sign (>). Used to complete tag display in text.
  • &amp; (&#38;) - Ampersand (&). MUST escape in HTML content and URLs.

Hands-on Practice Tools for this Course

Test what you learn using these free in-browser developer utilities (no signup required).

All 40+ Tools

Topics in This Module

0/5 done