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.
- < — less-than (<). Required to display < without starting a tag.
- > — greater-than (>). Technically safe unescaped in most contexts, but good practice to escape.
- " — double quote ("). Required inside double-quoted attributes.
- ' — apostrophe ('). Required inside single-quoted attributes; not valid in HTML4.
- — 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 © for © and — for —. You can also reference any Unicode character by its code point: © is the decimal form of ©, and © 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 ©, type — instead of —, 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 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&page=2' should have & 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.