In HTML, some characters can’t be typed directly into the code because the browser might interpret them as HTML commands or they might not be available on your keyboard.
HTML entities are special codes that represent these characters.


1. Why HTML Entities are Needed

  • To display reserved characters like < or > (used in tags).
  • To display special symbols like ©, ®, €, etc.
  • To show characters from other languages without encoding issues.

Example:

<p>2 &lt; 5 and 5 &gt; 2</p>

Output:
2 < 5 and 5 > 2


2. Structure of an HTML Entity

There are two types:

  1. Named entities: Start with &, end with ;&copy; → ©
  2. Numeric entities:
    • Decimal: &#169; → ©
    • Hexadecimal: &#x00A9; → ©

3. Commonly Used HTML Entities

SymbolNamed EntityNumeric CodeDescription
<&lt;&#60;Less than sign
>&gt;&#62;Greater than sign
&&amp;&#38;Ampersand
"&quot;&#34;Double quote
'&apos;&#39;Apostrophe / single quote
©&copy;&#169;Copyright
®&reg;&#174;Registered trademark
&trade;&#8482;Trademark
&euro;&#8364;Euro currency
&#8377;&#8377;Indian Rupee
£&pound;&#163;British Pound
¥&yen;&#165;Japanese Yen
&nbsp;&#160;Non-breaking space

4. Non-Breaking Space (&nbsp;)

This entity is especially useful for keeping words together without breaking into a new line.
Example:

<p>Price: 100&nbsp;USD</p>

Output: Price: 100 USD (the space won’t break to a new line).


5. Example Usage

<p>&copy; 2025 MyWebsite. All rights reserved.</p>
<p>5 &gt; 2 and 2 &lt; 5</p>
<p>Price: &euro;50 or &#8377;4200</p>

Output:
© 2025 MyWebsite. All rights reserved.
5 > 2 and 2 < 5
Price: €50 or ₹4200


Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *