What Are HTML Entities? A Practical Guide With Examples

If you have ever typed <b> into a web page and watched your text turn bold instead of showing the characters, you have met the reason HTML entities exist. They let you display characters that HTML would otherwise treat as code, and they play a quiet but vital role in website security. So what are HTML entities, and when do you actually need them?

Screenshot of the HTML Entity Encoder on Assen Tools
The HTML Entity Encoder in use. Open the HTML Entity Encoder – free, no sign-up.

The definition

An HTML entity is a short code that represents a character. It starts with & and ends with ;. Browsers display the character, not the code.

Entities come in two forms:

  • Named: &lt; for <
  • Numeric: &#60; (decimal) or &#x3C; (hexadecimal) for the same character

The five you must know

These characters have special meaning in HTML, so they must be written as entities when you want to show them as text – a process called using escape characters:

  • &lt; → <
  • &gt; → >
  • &amp; → &
  • &quot; → "
  • &#39; → ' (apostrophe)

Example: to show the text <p> on a coding tutorial, write &lt;p&gt;.

Useful special symbols

  • &nbsp; – a non-breaking space, which stops two words being split across lines (for example, "10 kg")
  • &copy; – ©
  • &reg; – ®
  • &trade; – ™
  • &euro; – €
  • &pound; – £
  • &#8358; – ₦ (the naira sign)
  • &hellip; – …
  • &mdash; – —

Do you still need entities in modern HTML?

If your page uses UTF-8 encoding (which almost all modern sites do), you can type most special symbols such as €, ₦ or é directly. Entities remain essential for the five reserved characters, for invisible characters like non-breaking spaces, and anywhere you are not sure the encoding will survive, such as some email templates. Read what is ASCII for how character encodings work.

The security side: preventing XSS

Cross-site scripting (XSS) is one of the most common web vulnerabilities. If a website shows user input – a comment, a name, a search term – without escaping it, an attacker can submit something like:

<script>stealCookies()</script>

and the browser will run it for every visitor. Converting < and > to &lt; and &gt; turns the attack into harmless text.

Modern frameworks escape output automatically – Laravel's Blade {{ }}, React's JSX and Django templates all do. The danger comes when developers bypass this to print raw HTML. Only output raw HTML you fully control or have sanitised.

Entities in other places

Encode and decode instantly

The free HTML Entity Encoder converts text to entities and back, handling named and numeric forms. It is useful for writing code tutorials, preparing email templates and checking what a strange code such as &#8217; means.

Related tools: URL Encode and Decode, Base64 Encode and Decode and the ASCII Converter.

Frequently asked questions

Are entity names case-sensitive? Yes. &Eacute; (É) and &eacute; (é) are different characters.

What does ’ mean? It is a right single quotation mark (’), often produced by word processors' "smart quotes".

Do I need to escape > as well as <? It is good practice for both, especially inside attribute values and user-generated content.

Why does my email show &amp; instead of &? The text was escaped twice – once by one system and again by another. Decode it once with the tool, then make sure only the final output step escapes characters.

Can entities be used in page titles and meta descriptions? Yes, and they are often necessary there. An ampersand in a title, for example, should be written as an entity in the HTML source so the page stays valid; browsers and search engines display the normal character.

Summary

So, what are HTML entities? Codes beginning with & and ending with ; that display characters HTML would otherwise treat as markup, plus invisible and special symbols. Always escape <, >, & and quotes in user content to prevent XSS. Convert text both ways with the free HTML Entity Encoder.

Jonathan Nwachukwu, founder of Assen Tools

Written by

Jonathan Nwachukwu · Founder & developer

Jonathan is a freelance web developer and web development teacher who builds Laravel, WordPress and WooCommerce sites for clients. He built AssenTools to put the everyday file, photo and calculation jobs he kept doing for clients and students into one free, private toolbox, and he maintains every tool and guide on the site.