Ctrl + K
HTML9 min read

HTML Entities Explained

Understand how HTML entities represent reserved and special characters safely in web pages.

Published: 2026-07-08

HTML entities are special codes used to display characters that would otherwise be interpreted as part of HTML markup or that cannot easily be typed on a keyboard. They allow developers to safely display reserved symbols, mathematical operators, currency signs, accented letters and many other Unicode characters inside HTML documents.

Without HTML entities, browsers might mistake certain characters for HTML tags or attributes, resulting in broken layouts or unexpected rendering.

Why HTML Entities Exist

Some characters have special meanings in HTML syntax. For example, the less-than symbol (<) begins an HTML tag, while the ampersand (&) starts an entity reference. To display these characters literally, they must be encoded as HTML entities.

&lt;div&gt;

&amp;

&quot;Hello&quot;

When rendered by a browser, these entities appear as normal characters rather than being interpreted as markup.

Reserved Characters

The most commonly encoded characters are those reserved by the HTML specification.

CharacterEntity
<&lt;
>&gt;
&&amp;
"&quot;
'&#39;
💡 The ampersand should almost always be written as &amp; unless it already begins a valid HTML entity.

Named Entities

Named entities use descriptive names that are easier for humans to read and remember.

&copy;

&nbsp;

&euro;

&trade;

Each named entity corresponds to a specific Unicode character defined by the HTML standard.

Numeric Entities

Instead of names, developers can reference characters by their Unicode code points using numeric entities.

&#169;

&#8364;

&#9731;

Numeric entities are especially useful for characters that do not have predefined named entities.

Decimal vs Hexadecimal

Numeric entities can be written using either decimal or hexadecimal notation.

CharacterDecimalHexadecimal
©&#169;&#xA9;
&#8364;&#x20AC;
&#9733;&#x2605;

Both forms produce exactly the same character when rendered by a browser.

Commonly Used HTML Entities

EntityCharacterMeaning
&nbsp; Non-breaking space
&copy;©Copyright
&reg;®Registered trademark
&trade;Trademark
&hellip;Ellipsis
&mdash;Em dash
&ndash;En dash
&deg;°Degree symbol

Non-Breaking Space

One of the most frequently used entities is the non-breaking space (&nbsp;). Unlike a normal space, it prevents browsers from wrapping text at that position.

100&nbsp;km

Mr.&nbsp;Smith

This is useful for keeping numbers with their units or preventing names from being split across lines.

Displaying HTML Code

When showing HTML examples inside tutorials or documentation, angle brackets must be encoded so browsers display the code instead of interpreting it.

&lt;p&gt;Hello World&lt;/p&gt;

This allows readers to see the markup exactly as written.

⚠️ Forgetting to escape reserved characters can break page structure or create security issues when displaying user-generated content.

Unicode and HTML Entities

Modern websites typically use UTF-8 encoding, allowing browsers to display most Unicode characters directly. Even so, HTML entities remain useful for reserved symbols and situations where explicit encoding improves readability or compatibility.

When Should You Use HTML Entities?

  • Display reserved HTML characters like <, > and &.
  • Show HTML code examples in tutorials.
  • Insert non-breaking spaces where wrapping should be prevented.
  • Represent special symbols such as ©, ™ or €.
  • Improve compatibility when working with generated HTML.

When You Don't Need Entities

Most ordinary letters, numbers and punctuation do not need to be encoded. With UTF-8, many international characters can also be written directly without using entities.

<p>Café München 東京</p>

As long as the document is saved using UTF-8, browsers display these characters correctly without requiring entity references.

Entities vs Unicode Characters

Direct CharacterHTML Entity
©&copy;
&euro;
&trade;
&rarr;
<&lt;

For reserved characters like < and &, entities are required. For many other symbols, either representation is acceptable when UTF-8 is used.

Common Mistakes

  • Forgetting to encode ampersands in HTML.
  • Displaying raw HTML instead of escaped code examples.
  • Using &nbsp; repeatedly for layout instead of CSS.
  • Assuming every Unicode character requires an HTML entity.
  • Mixing encoded and unencoded reserved characters inconsistently.
💡 Use CSS for spacing and layout. The non-breaking space should only be used when preventing a line break is the actual goal.

HTML Encoding and Security

Encoding reserved characters is also an important security practice. Applications that display user-generated content should escape HTML before rendering it to help prevent markup injection and cross-site scripting (XSS) vulnerabilities.

User input:
<script>alert("Hello")</script>

Escaped output:
&lt;script&gt;alert("Hello")&lt;/script&gt;

After encoding, the browser displays the text exactly as written instead of executing it as HTML or JavaScript.

Frequently Asked Questions

Do modern websites still use HTML entities?

Yes. They are still required for reserved HTML characters and are commonly used for certain symbols and code examples.

Can I type Unicode characters directly?

Yes. With UTF-8 encoding, most Unicode characters can be written directly in HTML documents.

Should every special character be converted into an entity?

No. Only reserved HTML characters must be escaped. Other Unicode characters can usually remain unchanged.

What is the difference between named and numeric entities?

Named entities use descriptive names such as &copy;, while numeric entities reference Unicode code points like &#169; or &#xA9;.

Why is &nbsp; different from a normal space?

A non-breaking space prevents browsers from wrapping text at that location, keeping words or values together.

Helpful HTML Tools

Several tools simplify working with HTML entities. An HTML Entity Lookup quickly finds the correct entity for any symbol, an HTML Encoder / Decoder converts reserved characters automatically, an HTML Formatter keeps markup readable, an HTML Tag Stripper extracts plain text from HTML documents, and an HTML to Markdown Converter transforms HTML into clean Markdown syntax.

Conclusion

HTML entities provide a safe and reliable way to display reserved characters, special symbols and HTML code inside web pages. While UTF-8 allows most Unicode characters to be written directly, entities remain essential for reserved markup characters and are still widely used in documentation, templates and user-generated content. Knowing when to encode characters helps create more reliable, secure and maintainable HTML documents.