HTML Character Entities Guide: Special Characters in HTML
Reference guide for HTML character entities. Learn how to display special characters, symbols, and Unicode in HTML using entity names and numeric codes.
Why HTML Entities Are Necessary
HTML uses certain characters as part of its syntax — angle brackets (< >) define tags, ampersands (&) begin entities, and quotes (") delimit attribute values. To display these characters as visible text rather than having the browser interpret them as code, you must use HTML entities. An entity starts with an ampersand and ends with a semicolon. The less-than symbol is <, the greater-than is >, the ampersand itself is &, and the double quote is ". Without entities, writing '<script>' in visible text would create an actual script tag, potentially enabling cross-site scripting (XSS) attacks. Entity encoding is a fundamental web security practice.
Named Entities vs. Numeric References
HTML supports three formats for entities. Named entities use memorable names: © for the copyright symbol, € for the euro sign, — for an em dash. Numeric decimal references use the Unicode code point: © is also the copyright symbol (Unicode U+00A9 = 169 decimal). Numeric hexadecimal references prefix with x: © is the same copyright symbol. Named entities are easier to read in source code, but only about 250 named entities exist while numeric references can represent any of Unicode's 149,000+ characters. Use named entities for common symbols and numeric references for rare characters or when maximum compatibility is needed.
Common Entities Every Developer Should Know
Mandatory escapes: < (<), > (>), & (&), " ("), ' ('). Typographic: — (em dash), – (en dash), … (ellipsis), « and » (guillemets). Spaces: (non-breaking space),   (en space),   (em space),   (thin space). Currency: $ ($), € (euro), £ (pound), ¥ (yen). Math: × (multiplication), ÷ (division), ± (plus-minus), ≤ (less-or-equal), ≥ (greater-or-equal). Arrows: ← (left), → (right), ↑ (up), ↓ (down). Miscellaneous: © (copyright), ® (registered), ™ (trademark), ° (degree), ¶ (paragraph mark).
Recommended Resources
Sponsored · We may earn a commission at no cost to you
Modern Alternatives to HTML Entities
With UTF-8 encoding now standard across the web, many characters can be typed directly in HTML source code without entities. If your HTML document declares <meta charset="UTF-8">, you can type most symbols, accented characters, and even emoji directly. Entities are still required for the five reserved HTML characters (<, >, &, ", ') and are useful for non-breaking spaces ( ) and characters that might not render correctly in all text editors. In JavaScript, use textContent or innerText instead of innerHTML to automatically handle escaping. Template engines and frameworks like React automatically escape content by default, preventing XSS vulnerabilities.
Related Free Tools
Related Articles
Frequently Asked Questions
Do I still need HTML entities if I use UTF-8?
You must always escape the five reserved HTML characters: < > & " ' — these have structural meaning in HTML regardless of character encoding. For all other characters (symbols, accented letters, emoji), UTF-8 encoding allows direct use in your HTML source. Entities for non-reserved characters are optional but can improve source code readability and ensure compatibility with older systems.
What is the difference between and a regular space?
A non-breaking space ( ) prevents the browser from breaking a line between two words at that position, and multiple consecutive entities are each rendered (unlike regular spaces, which browsers collapse into one). Use between words that should stay together (like '100 km' or 'Dr. Smith') and for creating visible spacing. Regular spaces are collapsed by HTML — ten consecutive spaces display as one.
How do I display HTML code in a web page?
Replace < with < and > with > in all HTML tags you want to display as text. For example, to show '<div class="test">', write '<div class="test">'. Use the <code> element for inline code and <pre><code> for multi-line blocks. Most syntax highlighting libraries handle entity encoding automatically when you pass code as a text string.