Skip to content

HTML Entities: Complete Reference Guide for Web Developers

What Are HTML Entities?

HTML entities are special codes that represent characters in HTML documents. They exist because certain characters have structural meaning in HTML — the less-than sign opens a tag, the ampersand begins an entity — and displaying these characters as literal text requires an escape mechanism.

Encode and decode HTML entities with WritePadPro's HTML Encoder & Decoder — paste any text and convert special characters to their entity equivalents, or paste encoded HTML to decode it back to readable text.

Every HTML entity starts with an ampersand and ends with a semicolon. Between them is either a name (named entity) or a number (numeric entity). The entity < renders as the less-than sign. The entity & renders as an ampersand. Without these entities, the browser would interpret these characters as HTML markup rather than displayable text.

HTML entities have been part of the web since the earliest versions of HTML in the early 1990s. While modern UTF-8 encoding has reduced the need for many entities, the five mandatory entities — for characters that would break HTML parsing — remain essential for every web developer.

Named vs Numeric Entities

HTML supports two formats for character entities: named and numeric.

Named Entities

Named entities use a descriptive word between the ampersand and semicolon. For example: & produces an ampersand, < produces a less-than sign, > produces a greater-than sign, © produces the copyright symbol, and — produces an em dash.

Named entities are easier to read and remember. HTML5 defines over 2,000 named entities, though most developers use only a small handful regularly.

Numeric Entities (Decimal)

Numeric entities use the character's Unicode code point as a decimal number. For example: & produces an ampersand (Unicode 38), < produces a less-than sign (Unicode 60), © produces the copyright symbol (Unicode 169).

Numeric Entities (Hexadecimal)

Same as decimal but using hex notation with an x prefix: & for ampersand, < for less-than, © for copyright, 🔥 for the fire emoji.

Which Format to Use?

FormatBest ForExample
NamedCommon characters with memorable names© for copyright
DecimalCharacters without named entities→ for right arrow
HexadecimalWhen working with Unicode code points directly→ for right arrow

Named entities are preferred for readability when available. Numeric entities cover any Unicode character. For URL-context encoding instead, see our URL Encoding Guide.

The 5 Mandatory HTML Entities

Encode these five characters whenever they appear in content that could be read as markup, especially user input. Strictly, & and < matter most in text content, and quotes matter inside attribute values, but encoding all five everywhere is the safe default. Skipping them can cause parsing errors, broken layouts, or security vulnerabilities.

CharacterNamed EntityNumericWhy It Must Be Encoded
Ampersand&amp;&#38;Starts entity sequences. Unencoded ampersand in text is interpreted as an entity beginning.
Less-than&lt;&#60;Opens HTML tags. Unencoded less-than starts an HTML element.
Greater-than&gt;&#62;Closes HTML tags. Encoding is required for validity and XSS prevention.
Double quote&quot;&#34;Terminates attribute values. Unencoded quotes inside attributes break HTML and enable XSS.
Single quote&apos;&#39;Terminates single-quoted attributes. Same XSS risk as double quote.

The Security Dimension: XSS Prevention

Cross-Site Scripting (XSS) attacks work by injecting HTML or JavaScript into web pages. If user input containing a script tag is displayed without encoding, the browser executes the script. Encoding converts the dangerous characters to harmless entity text. Most modern frameworks and template engines (React, Django, Laravel Blade, Rails) escape user content by default when rendering it. WritePadPro's HTML Encoder & Decoder handles this conversion instantly.

Complete HTML Entity Reference

Below are the most commonly used HTML entities organized by category.

Typography Entities

EntityDescription
&mdash;Em dash — used for parenthetical breaks
&ndash;En dash — used for ranges (1-10)
&hellip;Horizontal ellipsis
&ldquo; / &rdquo;Left/right double quotation marks
&lsquo; / &rsquo;Left/right single quotation marks
&nbsp;Non-breaking space
&middot;Middle dot (interpunct)
&bull;Bullet
&dagger; / &Dagger;Dagger / double dagger (footnote markers)
&para;Paragraph sign (pilcrow)
&sect;Section sign

Currency Entities

EntityDescription
&euro;Euro sign
&pound;British pound
&yen;Japanese yen / Chinese yuan
&cent;Cent sign
&curren;General currency symbol

Mathematical Entities

EntityDescription
&times;Multiplication sign
&divide;Division sign
&plusmn;Plus-minus
&ne;Not equal
&asymp;Approximately equal
&le; / &ge;Less/greater than or equal
&infin;Infinity
&sum;Summation
&radic;Square root
&deg;Degree sign

Arrow Entities

EntityDescription
&larr; / &rarr;Left/right arrow
&uarr; / &darr;Up/down arrow
&harr;Left-right arrow
&lArr; / &rArr;Left/right double arrow

Legal and Intellectual Property

EntityDescription
&copy;Copyright
&reg;Registered trademark
&trade;Trademark

For previewing HTML with entities, use the HTML Preview tool. For another encoding guide, see our Base64 Guide.

When HTML Entities Are Required

1. Displaying Code in HTML

Showing HTML code as visible text requires encoding every tag. Without encoding, the browser interprets the tags as HTML and renders the content — not as visible code.

2. Preventing XSS Attacks

Any user-generated content displayed on a webpage must have the five mandatory characters encoded. This includes comment sections, forum posts, profile fields, search result excerpts, error messages that echo user input, and any dynamic content from databases.

3. Typographic Characters

Curly quotes, em dashes, en dashes, and ellipses should use entities or Unicode characters rather than their ASCII approximations. This produces better typography across all browsers and operating systems.

4. Non-Keyboard Characters

Characters not available on standard keyboards — copyright, registered trademark, trademark, euro, degree, multiplication, division, arrows — require either entities or direct Unicode input. Entities are more explicit and work reliably even in documents with ambiguous encoding settings.

UTF-8 vs HTML Entities

Modern web development uses UTF-8 as the default character encoding, which supports every Unicode character directly.

When UTF-8 Makes Entities Unnecessary

With UTF-8 encoding in your HTML, you can type most special characters directly — copyright symbol, euro symbol, em dash — without entities. The browser renders them correctly from the UTF-8 encoded bytes.

When Entities Are Still Required

  • The 5 mandatory characters must always be encoded in text content and attribute values, regardless of UTF-8 support.
  • Non-breaking spaces have specific semantic meaning — they prevent line breaks between words.
  • HTML email — some email clients and sending systems still mishandle UTF-8, so entities can be safer for special characters.
  • XML and XHTML — stricter parsing rules require entities for the mandatory five characters.

The Practical Recommendation

Use UTF-8 encoding for all documents (it is the HTML5 default). Use HTML entities for the 5 mandatory characters, non-breaking spaces, and any character that causes rendering issues. For everything else — accented letters, symbols, emoji — type the Unicode character directly.

Using WritePadPro's HTML Encoder

WritePadPro's HTML Encoder & Decoder converts between plain text and HTML-encoded text instantly.

Step 1: Open the Tool

Navigate to the HTML Encoder & Decoder. You will see an input area with Encode and Decode buttons.

Step 2: Encode Text

Choose Encode, paste any text containing special characters, and click Encode / Decode. The tool converts ampersands, less-than signs, greater-than signs, and double quotes to named entities, and single quotes to &#39;. Tick "Encode non-ASCII characters and emoji as numeric entities" to also convert accented letters, symbols, and emoji to hex (the default) or decimal numeric entities.

Step 3: Decode Entities

Choose Decode, paste HTML-encoded text, and click Encode / Decode. The tool converts named, decimal, and hex entities back to their original characters. Any tags in the text stay as plain text and are never run.

Step 4: Copy and Use

Copy or download the result for HTML templates, CMS content fields, email HTML, or any context where special characters need escaping.

Privacy

All encoding and decoding runs locally in your browser. No text is transmitted to any server.

Summary

HTML entities represent special characters using codes that start with an ampersand and end with a semicolon. Named entities are readable, while numeric entities cover every Unicode character.

Five entities are mandatory for security and correct parsing: ampersand, less-than, greater-than, double quote, and single quote entities. Failing to encode these in user-generated content creates XSS vulnerabilities. Modern UTF-8 encoding reduces the need for most other entities, but the mandatory five remain essential.

Encode and decode HTML entities with WritePadPro's HTML Encoder & Decoder — instant conversion in your browser. For URL-context encoding, see our URL Encoding Guide. For binary-to-text encoding, see the Base64 Guide.

Frequently Asked Questions

What are the 5 HTML entities you must always use?

The five mandatory HTML entities encode the ampersand, less-than sign, greater-than sign, double quote, and single quote. These characters have structural meaning in HTML — the less-than sign opens tags, the ampersand starts entity sequences, and quotes delimit attributes. Displaying them as literal text requires encoding. Failing to encode them in user-generated content creates Cross-Site Scripting (XSS) security vulnerabilities. Every web application must encode these characters when rendering user input.

What is the difference between named and numeric HTML entities?

Named entities use descriptive words like amp, lt, copy, and mdash. Numeric entities use the Unicode code point as a number — either decimal or hexadecimal. Named entities are easier to read and remember but not every character has one. Numeric entities can represent any Unicode character, including emoji. Use named entities for common characters and numeric entities for characters without named equivalents.

Do I still need HTML entities with UTF-8 encoding?

Partially. With UTF-8 encoding (the HTML5 default), you can type most special characters directly without entities. However, you still MUST use entities for the five mandatory characters because they have structural meaning in HTML regardless of encoding. You also need the non-breaking space entity for semantic non-breaking spaces, and entities remain safer than raw characters in HTML email where UTF-8 support is inconsistent.

How do HTML entities prevent XSS attacks?

Cross-Site Scripting (XSS) works by injecting executable code into web pages through user input. If a user submits a script tag and the site displays it without encoding, the browser executes the JavaScript. Encoding converts the dangerous less-than and greater-than characters to entity form, which the browser displays as harmless visible text rather than executing as code. This is why the five mandatory entities are a security requirement. Most modern web frameworks and template engines do this encoding by default.

What is the non-breaking space entity and when should I use it?

The non-breaking space entity looks like a regular space but prevents the browser from breaking the line at that point. Use it between words that should stay together on one line — for example, between a title and a name, between a number and its unit, or between a currency symbol and an amount. Do not use non-breaking spaces for general spacing or indentation — use CSS margins and padding instead.

Try These Tools

Related Articles