HTML Entities


HTML entities are special codes used to display reserved characters or symbols in HTML that would otherwise be interpreted as HTML code. They help show characters like <, >, &, or special symbols such as ©, ®, £, etc.


🔹 Why Use HTML Entities?

  • To display characters reserved by HTML (like < and >)

  • To show special symbols not available on keyboard

  • To avoid conflicts with HTML parsing


🔹 Syntax of HTML Entities

  • Named Entity: &entity_name;
    Example: &lt; for <

  • Numeric Entity: &#number; (decimal)
    Example: &#60; for <

  • Hexadecimal Entity: &#xhex_number;
    Example: &#x3C; for <


💻 Common HTML Entities Table

Symbol Named Entity Decimal Hexadecimal Description
< &lt; &#60; &#x3C; Less than
> &gt; &#62; &#x3E; Greater than
& &amp; &#38; &#x26; Ampersand
" &quot; &#34; &#x22; Double quote
' &apos;* &#39; &#x27; Single quote (apostrophe)
© &copy; &#169; &#xA9; Copyright symbol
® &reg; &#174; &#xAE; Registered trademark
&euro; &#8364; &#x20AC; Euro sign

*Note: &apos; is not supported in older versions of HTML but works in XHTML and HTML5.


💻 Example: Using HTML Entities

<p>Use &lt;strong&gt; to make text bold.</p>
<p>Price: &euro;100</p>
<p>Copyright &copy; 2025 My Website</p>
<p>Use &amp; to display an ampersand.</p>

Practice Questions

Q1. Write HTML to display <html> tags on a page using entities.

Q2. Show the text: Tom & Jerry correctly with the ampersand.

Q3. Display the copyright symbol © using entities.

Q4. Write a paragraph that includes quotes "Hello" using entities.

Q5. Show the registered trademark symbol ® in HTML.

Q6. Use numeric entity to display less than < symbol.

Q7. Display an email address with @ sign properly escaped.

Q8. Show the Euro sign € using a named entity.

Q9. Encode a sentence with multiple special characters: <, >, &.

Q10. Create a list showing different quotation marks using HTML entities.


HTML Entities Quiz

Q1: What does &lt; represent?

A. Greater than symbol >
B. Less than symbol <
C. Ampersand &
D. Quotation mark "

Q2: Which entity represents the ampersand?

A. &amp;
B. &and;
C. &anp;
D. &anm;

Q3: How do you write the copyright symbol using an entity?

A. &cop;
B. &copy;
C. &cp;
D. &copyright;

Q4: What is the numeric entity for the less than symbol <?

A. &#38;
B. &#62;
C. &#60;
D. &#39;

Q5: Which entity shows the Euro currency sign?

A. &dollar;
B. &euro;
C. &pound;
D. &yen;

Q6: Which is NOT a correct way to write an HTML entity?

A. &nbsp;
B. &#169;
C. &#xA9;
D. %copy%

Q7: The entity &quot; is used for which character?

A. Single quote '
B. Double quote "
C. Ampersand &
D. Greater than >

Q8: What does the &apos; entity represent?

A. Double quote "
B. Less than <
C. Single quote '
D. Ampersand &

Q9: Which of the following is the hexadecimal form of >?

A. &#x3E;
B. &#x3C;
C. &#x26;
D. &#x22;

Q10: Why use HTML entities?

A. To display reserved characters safely
B. To speed up page loading
C. To compress HTML files
D. To change text color

Go Back Top