Special Characters

HTML Entities

Display special characters, symbols, and reserved HTML characters safely using HTML entities. Essential for proper text rendering and avoiding parsing conflicts.

What are HTML entities?

HTML entities are codes for characters that would otherwise be read as markup, or that are hard to type. The essential ones are &lt; for <, &gt; for >, &amp; for & and &quot; for ". Each entity starts with & and ends with ;, and you can also use numeric codes like &#169; for ©.

<p>Use &lt;p&gt; for paragraphs.</p>   <!-- shows: Use <p> for paragraphs. -->
<p>&copy; 2025 Compileum &middot; Terms &amp; Privacy</p>
<p>10&nbsp;km</p>   <!-- non-breaking space -->

Understanding HTML Entities

HTML entities are special codes that represent characters which have special meaning in HTML or characters that can't be easily typed. They prevent parsing conflicts and ensure proper display across all devices and browsers.

Safe Display

Display reserved HTML characters safely

International

Support for multiple languages and symbols

Universal

Consistent display across all browsers

Types of HTML Entities

Named Entities

&lt; → < (less than)

&gt; → > (greater than)

&amp; → & (ampersand)

&copy; → © (copyright)

&euro; → € (euro sign)

Numeric Entities

&#60; → < (decimal)

&#x3C; → < (hexadecimal)

&#169; → © (decimal)

&#x2014; → — (hex em dash)

&#8364; → € (decimal euro)

Comprehensive HTML Entities Reference

Complete reference of HTML entities including mathematical symbols, currency signs, accented characters, arrows, and special punctuation.

Code Editor

<p>Show code safely: &lt;p&gt;Hello&lt;/p&gt;</p>
<p>Ampersand: Tom &amp; Jerry</p>
<p>Non-breaking space keeps "10&nbsp;km" together.</p>
<p>&copy; &reg; &trade; &euro; &pound; &rarr; &hearts;</p>
<p>Numeric: &#169; &#x1F680;</p>

Preview

Best Practices & Guidelines

When to Use Entities

  • • Always encode <, >, and & in content
  • • Use for quotation marks in attributes
  • • Mathematical and scientific symbols
  • • Copyright and trademark symbols
  • • Non-breaking spaces and special spacing

Performance Tips

  • • Use UTF-8 encoding when possible
  • • Prefer named entities over numeric
  • • Don't over-encode regular text
  • • Use entities only when necessary
  • • Test across different browsers

HTML Entities Checklist

  • Always encode reserved HTML characters
  • Use appropriate entities for symbols
  • Test display across browsers
  • Consider accessibility implications
  • Use UTF-8 encoding properly
  • Document entity usage for team

HTML Entities — step by step

1 / 4
1

Understand why entities exist

Some characters have special meaning in HTML (like < and >). To display them as literal text, you must use HTML entities so the browser doesn't interpret them as code.

1 of 4
💡Always Escape User Content
Any user-supplied content rendered into HTML must have its special characters escaped. Unescaped input like a username containing a script tag can create a Cross-Site Scripting (XSS) vulnerability. Always use your framework's escaping or sanitization utilities.

🎯 Quick Check

Which HTML entity displays the less-than symbol as visible text?

HTML Entities: summary

Key points

  • You must escape < and & in text content; escape " inside double-quoted attribute values.
  • &nbsp; is a non-breaking space that keeps two words on the same line. Don't use it for layout spacing.
  • With <meta charset="UTF-8"> you can type most symbols (©, €, emoji) directly.

Frequently asked questions

›How do I show HTML code on a web page?

Escape the angle brackets as &lt; and &gt;, and wrap the code in <pre><code>…</code></pre>.

›What is &nbsp;?

A non-breaking space: a space that the browser won't wrap a line at and won't collapse with other spaces.