HTML & Web Development 2. HTML Basics 11 mins read 14,905 views

HTML Entities: Syntax, Common Codes, and Examples

HTML entities are coded character sequences used to display reserved characters (like , and &) and invisible characters without confusing the browser's HTML par...
Published: Nov 1, 2026Last Updated: Nov 21, 2026Curriculum: Class 12 / AP Physics / JEE-NEETReviewed by: OperateTools Editorial Board
Quick Summary & Direct Answer (AEO / GEO Extraction)

What is HTML Entities: Syntax, Common Codes, and Examples? HTML entities are coded character sequences used to display reserved characters (like , and &) and invisible characters without confusing the browser's HTML par...

Audience & Scope: Students, educators, and candidates preparing for academic examinations and technical assessments in Html & Web Development.
What are HTML entities, why are they required, and how do you write them?
HTML entities are coded character sequences used to display reserved characters (like <, >, and &) and invisible characters without confusing the browser's HTML parser. They start with an ampersand (&) and conclude with a semicolon (;), written as either an entity name (&lt;) or entity number (&#60;).

Explanation & In-Depth Details

1) Why Reserved Characters Break HTML: The characters '<', '>', '&', and '"' are reserved by the HTML grammar. Typing '<script>' in body text triggers tag parsing; typing '&lt;script&gt;' safely renders the literal characters on screen.

2) Entity Names vs Entity Numbers: Entity names (&copy;, &amp;) are human-readable and easy to remember. Entity numbers (&#169;, &#38;) use numerical Unicode codepoints and offer 100% universal browser and parser support.

3) Common HTML Reserved Entities:
- Less-than: &lt; (&#60;)
- Greater-than: &gt; (&#62;)
- Ampersand: &amp; (&#38;)
- Double quotation: &quot; (&#34;)
- Single quote / apostrophe: &apos; (&#39;)

4) Copyright and Commercial Symbols:
- Copyright: &copy; (&#169;)
- Registered Trademark: &reg; (&#174;)
- Trademark: &trade; (&#8482;)

5) Non-Breaking Space: The &nbsp; entity forces a space between two words that browsers cannot break into a new line.

Code Example

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>HTML Entities Guide</title>
</head>
<body>
    <h2>HTML Entities Demonstration</h2>
    
    <!-- Displaying code safely -->
    <p>To declare a paragraph, write <code>&lt;p&gt;Your Text&lt;/p&gt;</code>.</p>
    
    <!-- Commercial symbols -->
    <p>OperateTools&trade; is a registered&reg; platform. &copy; 2026.</p>
    
    <!-- Quotations and Ampersand -->
    <p>Tom &amp; Jerry said: &quot;Learning HTML is fun!&quot;</p>
    
    <!-- Pricing and Currency -->
    <p>Price: &euro;49.99 or &pound;42.50 or &#36;55.00</p>
</body>
</html>

Interview Question & Tips

Q1: What happens if you forget to encode the ampersand (&) in body text or query strings?
A1: If the text following the ampersand matches a recognized entity name (e.g. '?sort=price&copy=true'), the browser may mistakenly parse '&copy' into the copyright symbol, corrupting URLs and markup.

Q2: Which is preferred: entity names (&lt;) or entity numbers (&#60;)?
A2: Entity names are easier for developers to read, but entity numbers have marginally broader support for uncommon Unicode characters. For standard symbols (&amp;, &lt;, &gt;, &copy;), entity names are the industry standard.

Q3: How do HTML entities prevent Cross-Site Scripting (XSS) attacks?
A3: By encoding user-submitted characters ('<' into '&lt;', '>' into '&gt;'), malicious scripts (<script>alert(1)</script>) are treated as harmless literal text rather than executable browser code.

Best Practices

Always encode user input into HTML entities before rendering it to the page to prevent XSS injection attacks.
Academic Standards & Verified Citations

This study reference for HTML Entities: Syntax, Common Codes, and Examples is curated and verified against recognized curriculum benchmarks, peer-reviewed textbooks, and official technical documentation:

HTML & Web Development