Skip to main content

HTML Entities & Special Characters

Mentor's Note: Have you ever typed <html> in a paragraph and watched it vanish into thin air? That's HTML treating your text as code! Entities are your escape hatch โ€” they let you show reserved characters, symbols, and emoji without breaking your page. Master these and you'll never get "eaten" by the browser again!

What are HTML Entities?โ€‹

HTML entities are special codes that represent characters which are either reserved in HTML or not available on your keyboard. When the browser sees an entity, it renders the corresponding character instead of interpreting it as code.

Common Reserved Charactersโ€‹

These five characters are reserved in HTML. If you type them directly in your content, the browser will try to interpret them as code. Always use entities for these:

CharacterEntity NameEntity NumberDescription
<&lt;&#60;Less than
>&gt;&#62;Greater than
&&amp;&#38;Ampersand
"&quot;&#34;Double quote
'&apos;&#39;Apostrophe / Single quote
(space)&nbsp;&#160;Non-breaking space

Symbol Entitiesโ€‹

EntityResultDescription
&copy;ยฉCopyright
&reg;ยฎRegistered trademark
&trade;โ„ขTrademark
&euro;โ‚ฌEuro currency
&pound;ยฃPound currency
&yen;ยฅYen currency
&dollar;$Dollar (not needed but shown)
&cent;ยขCent
&sect;ยงSection
&para;ยถParagraph
&deg;ยฐDegree
&plusmn;ยฑPlus-minus
&times;ร—Multiplication
&divide;รทDivision
&lt;<Less than
&gt;>Greater than
&amp;&Ampersand
&quot;"Double quote
&apos;'Apostrophe
&nbsp;(space)Non-breaking space

Mathematical Symbol Entitiesโ€‹

EntityResultDescription
&forall;โˆ€For all
&part;โˆ‚Partial differential
&exist;โˆƒThere exists
&empty;โˆ…Empty set
&nabla;โˆ‡Nabla
&isin;โˆˆElement of
&notin;โˆ‰Not element of
&sum;โˆ‘Summation
&prod;โˆProduct
&radic;โˆšSquare root
&alpha; - &omega;ฮฑ - ฯ‰Greek letters

Arrow & Icon Entitiesโ€‹

EntityResultDescription
&larr;โ†Left arrow
&uarr;โ†‘Up arrow
&rarr;โ†’Right arrow
&darr;โ†“Down arrow
&harr;โ†”Left-right arrow
&spades;โ™ Spade
&clubs;โ™ฃClub
&hearts;โ™ฅHeart
&diams;โ™ฆDiamond

Using Entities in HTMLโ€‹

Entities always start with an ampersand (&) and end with a semicolon (;). Here's how they work in context:

<p>To save a file, press Ctrl + S.</p>
<p>The &lt;h1&gt; tag is the main heading in HTML.</p>
<p>ยฉ 2025 My Company. All rights reserved.</p>
<p>Price: &pound;29.99 (approx. &euro;34.99)</p>
<p>Water boils at 100&deg;C (&plusmn;1&deg;).</p>

Browser output:

To save a file, press Ctrl + S. The <h1> tag is the main heading in HTML. ยฉ 2025 My Company. All rights reserved. Price: ยฃ29.99 (approx. โ‚ฌ34.99) Water boils at 100ยฐC (ยฑ1ยฐ).

Character Encodingโ€‹

Before entities even come into play, your browser needs to know what character set your page uses. This is where <meta charset="UTF-8"> comes in:

Always include this tag in the <head> of your HTML documents:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>My Page</title>
</head>
<body>
<!-- your content -->
</body>
</html>

Named vs Numeric Entitiesโ€‹

Entities come in two flavors:

FeatureNamed EntityNumeric Entity
Format&amp;&#38;
ReadabilityEasy to read and rememberHarder to read
Browser supportWidely supportedSupported everywhere
Character coverageOnly common symbolsAny Unicode character
Best forEveryday use (copyright, arrows, quotes)Rare or obscure characters

Verdict: Use named entities when possible. Use numeric entities when no named version exists.

Emoji in HTMLโ€‹

Most emoji work directly in HTML thanks to UTF-8 encoding โ€” no entity needed:

<p>I โค๏ธ coding! ๐Ÿš€ Let's build something awesome! ๐ŸŽ‰</p>

If you prefer (or need) the hex reference, you can use:

<p>I &#x2764;&#xFE0F; coding! &#x1F680; Let's build something awesome! &#x1F389;</p>

Both produce: I โค๏ธ coding! ๐Ÿš€ Let's build something awesome! ๐ŸŽ‰

When NOT to Use Entities (Common Mistakes)โ€‹

MistakeWhy It's WrongWhat To Do Instead
&nbsp;&nbsp;&nbsp; for spacingHTML collapses whitespace, but abusing &nbsp; for layout is fragileUse CSS margin or padding
&nbsp; to indent paragraphsWrong tool for the jobUse CSS text-indent
&lt;br&gt;&lt;br&gt; for spacingLine breaks aren't meant for marginsUse CSS margin-bottom
Using &amp; in URLs (correctly)Actually this one is correct inside HTML โ€” but don't over-encodeOnly encode & in URLs inside HTML attributes

Rule of thumb: Entities are for content (displaying special characters). CSS is for layout and spacing.

Quick Reference โ€” 10 Essential Entitiesโ€‹

Memorize these and you'll be covered for 95% of cases:

#EntityResultWhy
1&lt;<Show HTML tags in text
2&gt;>Show HTML tags in text
3&amp;&Avoid breaking your markup
4&quot;"Safe quotes in attributes
5&apos;'Safe apostrophes in attributes
6&nbsp;(space)Prevent line breaks between words
7&copy;ยฉCopyright notice
8&euro;โ‚ฌEuro currency
9&deg;ยฐTemperature / angles
10&rarr;โ†’Point to something

Try It Yourselfโ€‹

Copy this into an HTML file and open it in your browser:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>HTML Entities Demo</title>
<style>
body { font-family: Arial, sans-serif; max-width: 600px; margin: 2rem auto; }
</style>
</head>
<body>
<h1>HTML Entities Demo</h1>

<h2>Reserved Characters</h2>
<p>The &lt;div&gt; tag is a block-level element.</p>
<p>Use &amp;amp; for the ampersand character.</p>

<h2>Symbols</h2>
<p>&copy; 2026 โ€” All rights reserved.</p>
<p>Price: &euro;49.99 (approx. &pound;42.00)</p>
<p>Water boils at 100&deg;C.</p>

<h2>Arrows</h2>
<p>Click the button &rarr; to continue.</p>
<p>Navigate using &larr; &uarr; &darr; &rarr; keys.</p>

<h2>Math</h2>
<p>3 &times; 4 = 12 &amp; 12 &divide; 3 = 4</p>
<p>Sum of all elements: &sum;x<sub>i</sub></p>
</body>
</html>


๐ŸŽฏ Next up: HTML Formatting โ€” Learn how to style text with bold, italic, underline, and more!