Day 1 - HTML Special Characters

HTML entities are used to display reserved characters in HTML.


1. Popular HTML Entities

Some characters are reserved in HTML (like < and >) because the browser interprets them as tags. To display these characters, we must use their *entity name* or *entity number*.

Common Entities Table:

Character Description Entity Name
< Less than &lt;
> Greater than &gt;
& Ampersand &amp;
" Double quote &quot;
' Single quote &apos;
  Non-breaking space &nbsp;
© Copyright &copy;

2. Usage Examples

Code:

<p>5 &lt; 10</p>
<p>10 &gt; 5</p>
<p>Tom &amp; Jerry</p>

Output:

5 < 10

10 > 5

Tom & Jerry


Code (Extra Spaces):

<p>Hello&nbsp;&nbsp;&nbsp;&nbsp;World!</p>

Output:

Hello    World!


Code (Copyright):

<p>&copy; 2024 Your Company Name</p>

Output:

© 2024 Your Company Name