HTML CSS Bootstrap JavaScript jQuery MySQL PHP Data Mining

HTML Entities

Some characters are reserved in HTML — for example, < and > are used for tags. To display these characters as text, you must use HTML entities.


What is an HTML Entity?

An HTML entity is a piece of text that starts with & and ends with ;. It represents a character that either:

  • Is reserved in HTML (like <, >, &)
  • Is not easily typed on a keyboard (like ©, ®, €)

Entities can be written as a named entity or a numeric entity:

&entity_name;     <!-- Named entity -->
&#entity_number;  <!-- Numeric (decimal) entity -->
&#xhex_number;   <!-- Numeric (hex) entity -->

Example — displaying the less-than sign <:

&lt;     <!-- Named entity -->
&#60;    <!-- Numeric (decimal) -->
&#x3C;   <!-- Numeric (hex) -->

Reserved Characters

These characters must be replaced with entities when used as content in HTML:

Character Description Entity Name Entity Number
<Less than&lt;&#60;
>Greater than&gt;&#62;
&Ampersand&amp;&#38;
"Double quote&quot;&#34;
'Single quote / apostrophe&apos;&#39;
Important: If you type < directly inside your HTML content without using &lt;, the browser may think it's the start of a tag and break your page layout.

Non-Breaking Space — &nbsp;

The most commonly used entity is the non-breaking space &nbsp;. It adds a space that will not collapse or line-break:

<p>10&nbsp;km</p>
<p>Hello&nbsp;&nbsp;&nbsp;World</p>

10 km

Hello   World


Common Special Character Entities

Character Description Entity Name Entity Number
 Non-breaking space&nbsp;&#160;
©Copyright&copy;&#169;
®Registered trademark&reg;&#174;
Trademark&trade;&#8482;
Euro sign&euro;&#8364;
£Pound sign&pound;&#163;
¥Yen sign&yen;&#165;
¢Cent sign&cent;&#162;
Em dash&mdash;&#8212;
En dash&ndash;&#8211;
«Left angle quotes&laquo;&#171;
»Right angle quotes&raquo;&#187;
Heart&#9829;
Star&#9733;

Combining Entities

Entities can be combined with regular text and other HTML tags:

<p>&copy; 2025 RedoHub. All rights reserved.</p>
<p>Price: &euro;29.99</p>
<p>5 &lt; 10 and 10 &gt; 5</p>

© 2025 RedoHub. All rights reserved.

Price: €29.99

5 < 10 and 10 > 5

Tip: Named entities like &copy; are easier to remember. Numeric entities like &#169; always work even in older browsers that may not recognise all named entities.