HTML Entities: The Complete Guide for Web Developers

Learn how to properly encode special characters, escape reserved symbols, and display professional typography using HTML entities.

What Are HTML Entities?

HTML entities are special codes that represent characters which cannot be directly typed or would otherwise be interpreted as HTML syntax. According to MDN Web Docs, an entity is a reference to information that can be defined once and used throughout a document in SGML terminology. In HTML specifically, entities enable you to display reserved characters, special symbols, and characters from various languages.

The entity syntax follows a consistent pattern: an ampersand (&) followed by either a name or number, then a semicolon (;). For example, &lt; renders as < and &copy; displays the copyright symbol (©).

Why Entities Exist

HTML has several characters that serve as syntax markers. The angle brackets < and > indicate the start and end of HTML tags. The ampersand (&) introduces special codes. When you want these characters to appear as visible text rather than functioning as code, you must use their entity representations, as explained in Elementor's HTML entities guide.

Beyond escaping reserved characters, entities unlock access to thousands of symbols, mathematical operators, currency signs, and international characters that aren't available on standard keyboards. This capability is essential for creating professional, globally accessible web content through proper web development practices.

Key Takeaway

Entities ensure your HTML renders correctly and enable access to special symbols that enhance professional presentation. When building websites that rank well in search results, proper character encoding prevents indexing issues caused by malformed HTML.

In This Guide

Quick navigation

What Are HTML Entities?

Understanding entity basics

Types of Entities

Named, decimal & hexadecimal

Reserved Characters

Essential escaping guide

Common Categories

Symbols, math & Greek letters

Best Practices

Modern entity usage

Accessibility

Screen reader considerations

Types of HTML Entities

HTML entities come in three formats, all producing identical results. Choose based on readability and context.

Named Entities

Named entities use descriptive words between the ampersand and semicolon. They are the most readable option and should be your default choice for common characters, as recommended by Elementor's HTML entities guide.

<!-- Reserved character escaping -->
&lt; <!-- displays < -->
&gt; <!-- displays > -->
&amp; <!-- displays & -->
&quot; <!-- displays " -->

<!-- Common symbols -->
&copy; <!-- © -->
&reg; <!-- ® -->
&quot; <!-- displays " -->

Decimal Entities

Decimal entities use a number sign (#) followed by the decimal Unicode code point of the character, as documented in Elementor's guide.

&#60; <!-- < (decimal 60) -->
&#62; <!-- > (decimal 62) -->
&#38; <!-- & (decimal 38) -->

Hexadecimal Entities

Hexadecimal entities use #x followed by the hexadecimal Unicode value, as shown in Elementor's documentation.

&#x3C; <!-- < (hex 3C) -->
&#x3E; <!-- > (hex 3E) -->
&#x26; <!-- & (hex 26) -->

All three formats produce identical results. Use named entities for readability with common characters, and decimal or hexadecimal entities when working with specific Unicode characters that lack named equivalents. Proper character encoding is a critical aspect of technical SEO that ensures search engines correctly parse and index your content.

Essential Reserved Characters and Their Entity Replacements
CharacterNamed EntityDecimalHexadecimalUse Case
<&lt;&#60;&#x3C;Display literal less-than
>&gt;&#62;&#x3E;Display literal greater-than
&&amp;&#38;&#x26;Display literal ampersand
"&quot;&#34;&#x22;Display quote in attribute
'&apos;&#39;&#x27;Display apostrophe
&euro;&#8364;&#x20AC;Euro currency symbol
GBP&pound;&#163;&#xA3;Pound currency symbol
¥&yen;&#165;&#xA5;Yen currency symbol

The Ampersand Rule

The ampersand is the most frequently misused character. Every ampersand in your HTML content (outside of entity definitions themselves) should be written as &amp;. This includes URLs in attributes, JavaScript code embedded in HTML, and any natural language text containing "AT&T" or similar, as emphasized by DhiWise's HTML entities article.

<!-- WRONG - will cause parsing errors -->
<p>Visit us at AT&T for more info</p>
<p>http://example.com?param1=value&param2=test</p>

<!-- CORRECT - properly escaped -->
<p>Visit us at AT&amp;T for more info</p>
<p>http://example.com?param1=value&amp;param2=test</p>

The ampersand requires special attention because browsers interpret unescaped ampersands as the start of a new entity reference. When an unrecognized sequence follows, browsers may display unexpected characters or truncate content unexpectedly. Always using &amp; prevents these parsing errors and ensures consistent rendering across all browsers and devices. This attention to detail is what separates amateur web development from professional-grade code that performs reliably in production environments.

Common Character Entity Categories

Symbols and Marks

These entities enable you to display legally required notices and professional typography, including copyright symbols, trademarks, and currency markers as documented by Elementor:

<p>&copy; 2026 Company Name. All rights reserved.</p>
<p>&reg; Registered Trademark</p>
<p>&trade; Trademark</p>
<p>Price: &euro;99.99</p>
<p>Cost: &pound;75.00</p>

Mathematical Operators

Common math symbols for educational content and technical documentation:

<p>5 &times; 3 = 15</p>
<p>100 &divide; 4 = 25</p>
<p>x &le; 10</p>
<p>x &ge; 0</p>
<p>A &isin; B</p>
<p>&pi; &approx; 3.14159</p>

Greek Letters

Greek letters used in math, science, and statistics contexts:

<p>Alpha: &alpha;</p>
<p>Beta: &beta;</p>
<p>Gamma: &gamma;</p>
<p>Delta: &delta;</p>
<p>Pi: &pi;</p>
<p>Sigma: &sigma;</p>
<p>Omega: &omega;</p>

Arrows

Directional and functional arrows for UI and navigation:

<p>&larr; Back</p>
<p>Next &rarr;</p>
<p>&uarr; Top</p>
<p>&darr; Expand</p>
<p>&harr; Swap</p>

Typography and Punctuation

Professional typography distinguishes polished content, as noted in Elementor's typography guide:

<p>&ldquo;Quoted text using smart quotes.&rdquo;</p>
<p>Single quote: &lsquo;inside&rsquo; content</p>
<p>Range: 10&ndash;20 pages</p>
<p>Break: This is a thought&mdash;continued.</p>
<p>Contact us&hellip;</p>

Non-Breaking Space

The non-breaking space (&nbsp;) prevents browsers from wrapping at that space. Use it between words that should stay together, as defined in the MDN character reference.

<p>Chapter&nbsp;1</p>
<p>Fig.&nbsp;5</p>
<p>$&nbsp;100.00</p>

Use cases:

  • Chapter and figure references
  • Currency symbols and amounts
  • Names and titles
  • Phone numbers

Don't overuse: Excessive non-breaking spaces can cause layout issues on narrow screens and impact accessibility on mobile devices.

Best Practices for Modern Web Development

UTF-8 Encoding

The most important practice is declaring UTF-8 encoding and using actual Unicode characters when your editor and font support them, as recommended by Elementor's HTML entities guide. Modern development environments handle UTF-8 natively, reducing the need for verbose entity references in your source code.

<!DOCTYPE html>
<html lang="en">
<head>
 <meta charset="UTF-8">
 <!-- Use actual characters when your setup supports them -->
 <p>© 2026 Company Name</p>
 <p>5 × 3 = 15</p>
</html>

However, entities remain essential for:

  • Reserved characters (<, >, &)
  • Characters in source code or examples
  • Environments without UTF-8 support
  • Maximum compatibility across systems

When to Use Entities

SituationRecommendation
Reserved characters (<, >, &)Always use entities
Characters in code examplesAlways use entities
Common symbols (©, ®, ™)Either (entities for safety)
Math/special symbolsUse entities or UTF-8
Content in modern appsUTF-8 with proper charset

Performance Considerations

HTML parsers handle entity references efficiently, so performance impact is negligible for typical usage. However, for pages with extensive special characters, using UTF-8 encoding reduces file size compared to verbose entity references, as noted by DhiWise. The performance difference is minimal for most websites, but can matter for high-traffic pages with significant content. Following these best practices is part of building websites that load fast and rank well in search engines.

Accessibility and Entities

Proper entity usage ensures that special characters are correctly interpreted and spoken by screen readers, as highlighted by DhiWise's accessibility discussion. When characters display as gibberish due to encoding issues, users with disabilities receive incorrect information, potentially impacting their understanding of your content.

<!-- Screen reader will correctly say "copyright" -->
<p>&copy; 2026 Company</p>

<!-- May be misread without proper encoding -->
<p>© 2026 Company</p> <!-- depends on page encoding -->

Semantic Correctness

Some symbols look similar but have different meanings. Use the correct entity rather than visual approximations for proper screen reader interpretation:

<!-- CORRECT - proper minus sign -->
<p>5 &minus; 3 = 2</p>

<!-- WRONG - hyphen is not a minus sign -->
<p>5 - 3 = 2</p>

<!-- CORRECT - proper multiplication -->
<p>5 &times; 3 = 15</p>

<!-- WRONG - letter x is not multiplication -->
<p>5 x 3 = 15</p>

Using semantically correct entities ensures assistive technologies convey the intended meaning, improving accessibility for all users regardless of how they access your content. This attention to accessibility is a hallmark of professional web development services that prioritize inclusive design.

Common Mistakes and How to Avoid Them

Double Encoding

Double encoding happens when entities are encoded multiple times, often through automated processing or copy-paste from sources that already escaped characters:

<!-- WRONG - double-encoded -->
<p>AT&amp;amp;T</p>
<!-- Displays as "AT&amp;T" -->

<!-- CORRECT -->
<p>AT&amp;T</p>
<!-- Displays as "AT&T" -->

Unclosed Entities

Forgetting the semicolon is a common mistake that can break rendering. Browsers try to recover by finding the next semicolon, but results are unpredictable:

<!-- WRONG - missing semicolon -->
<p>Price: &euro 99</p>

<!-- CORRECT -->
<p>Price: &euro;99</p>

Using HTML Entities in Wrong Contexts

Entities are for HTML content only. Other contexts require different escaping approaches:

<!-- In HTML content - use entities -->
<p>Use &lt;code&gt; tags</p>

<!-- In JavaScript - no entities needed -->
<script>
 let text = "<p>Hello</p>";
</script>

<!-- In CSS content - use CSS escape -->
<style>
 .warning::after {
 content: "\26A0"; /* Unicode hex for warning symbol */
 }
</style>

Understanding these context differences prevents common bugs and ensures your special characters display correctly everywhere. Building a strong foundation in these fundamentals through comprehensive web development learning resources sets you up for long-term success.

Entity Reference Quick Guide

The most common entities developers need daily

Essential Escaping

< = &lt; | > = &gt; | & = &amp;

Common Symbols

© = &copy; | ® = &reg; | ™ = &trade;

Currency

€ = &euro; | GBP = &pound; | ¥ = &yen;

Math Operators

× = &times; | ÷ = &divide; | ± = &plusmn;

Math Relations

≤ = &le; | ≥ = &ge; | ≈ = &approx;

Greek Letters

π = &pi; | α = &alpha; | Ω = &omega;

Typography

- = &ndash; | -- = &mdash; | ... = &hellip;

Arrows

← = &larr; | → = &rarr; | ↑ = &uarr;

Quotes

" = &ldquo;/&rdquo; | ' = &lsquo;/&rsquo;

Build Better Websites with Proper Character Handling

Master these HTML entity fundamentals to ensure your content displays correctly across all browsers and devices.