HTML Entities

What are HTML Entities?

HTML entities are special characters used to display characters that have special meaning in HTML or characters that cannot be typed on a keyboard. They're written as &entity_name; or &#entity_number;. HTML entities are essential for displaying reserved characters correctly.

Why Use HTML Entities?

HTML entities are used for:

Common HTML Entities

Here are the most commonly used HTML entities:

Reserved Characters

Characters with special meaning in HTML must be escaped:

Example
<p>Use &lt;div&gt; for containers.</p>
<p>The price is &lt; $10 &amp; &gt; $5.</p>
<p>Use &quot;quotes&quot; for text.</p>

Common Reserved Character Entities

Character Entity Name Entity Number Description
< &lt; &#60; Less than
> &gt; &#62; Greater than
& &amp; &#38; Ampersand
" &quot; &#34; Double quote
' &apos; &#39; Single quote (apostrophe)

Special Character Entities

Common special characters and symbols:

Character Entity Name Entity Number Description
  &nbsp; &#160; Non-breaking space
© &copy; &#169; Copyright symbol
® &reg; &#174; Registered trademark
&trade; &#8482; Trademark symbol
&euro; &#8364; Euro symbol
£ &pound; &#163; Pound symbol
¥ &yen; &#165; Yen symbol

Using HTML Entities

Example
<p>Copyright &copy; 2025 My Website</p>
<p>Price: &pound;10 &amp; &euro;12</p>
<p>HTML uses &lt;tags&gt; for markup.</p>
<p>Use &quot;quotes&quot; in attributes.</p>

Entity Name vs. Entity Number

You can use either entity names or entity numbers. Entity names are easier to remember, but entity numbers work in all browsers:

Example - Entity Name
<p>Copyright &copy; 2025</p>
Example - Entity Number
<p>Copyright &#169; 2025</p>

Non-Breaking Space

The non-breaking space entity (&nbsp;) prevents line breaks between words:

Example
<p>Mr.&nbsp;John&nbsp;Doe</p>
<p>5&nbsp;miles</p>
<p>January&nbsp;15,&nbsp;2025</p>

Best Practices