Quick Tools Online

HTML Special Characters and Entities: A Complete Guide

2026-01-07

HTML uses certain characters as part of its syntax: angle brackets delimit tags, ampersands introduce entities, and quotes delimit attribute values. If you want to display these characters as literal text in a webpage, you cannot simply type them — the browser will interpret them as markup. HTML entities are the solution: escape sequences that represent characters that would otherwise be ambiguous or illegal in HTML.

The Essential Entities

  • & — ampersand (&). Always escape & in HTML content and attribute values.
  • &lt; — less-than (<). Required to display < without starting a tag.
  • &gt; — greater-than (>). Technically safe unescaped in most contexts, but good practice to escape.
  • &quot; — double quote ("). Required inside double-quoted attributes.
  • &apos; — apostrophe ('). Required inside single-quoted attributes; not valid in HTML4.
  • &nbsp; — non-breaking space. Prevents a line break at this space; also displays as a visible space.

Named vs. Numeric Entities

HTML defines named character references like &copy; for © and &mdash; for —. You can also reference any Unicode character by its code point: &#169; is the decimal form of ©, and &#xA9; is the hexadecimal form. Named entities are easier to read; numeric entities work for any Unicode character, including those without named equivalents. Both forms are terminated by a semicolon.

When You Actually Need Entities

In modern web development, if your HTML file is saved as UTF-8 and served with the correct Content-Type header or a <meta charset='UTF-8'> declaration, you can include any Unicode character directly in your HTML source — no entity needed. You can type © directly instead of &copy;, type — instead of &mdash;, and type emoji directly. The only characters that truly require entities are the ones with syntactic meaning: &, <, and > in content, and additionally &, <, >, ', and " inside attribute values.

The &nbsp; entity is a special case. It is not just a space — it is a non-breaking space, which prevents the browser from inserting a line break between the words it connects. Use it intentionally, not as a way to add extra horizontal spacing. For spacing in CSS, use margin, padding, or gap instead.

Common Mistakes

The most common mistake is forgetting to escape & in URLs inside HTML. href='/search?q=cats&amp;page=2' should have &amp; where the & appears, not a raw &. Browsers are often lenient about this, but validators will flag it and some parsers will misread the attribute. The second common mistake is over-escaping — converting every apostrophe, dash, and quote to an entity when the character could just be typed directly with a UTF-8 encoded file.