Skip to content

HTML entities explained: when & and < actually matter

Blog / Published 

An HTML entity is a way to write a character that would otherwise be read as markup or that is hard to type. The ampersand, the less-than sign and the quotation mark all have special meanings in HTML, so a page that shows them as plain text has to write them as entities. Most of the time a template or a framework does this for you. The cases where it does not are where bugs and security holes appear.

The entities you meet every day

Five named entities cover most of the cases:

  is a non-breaking space. It looks like a space but it does not allow a line break, which is why it appears in prices and addresses.

Numeric references

Any character can be written by its code point. © is the decimal reference for the copyright sign and © is the same character in hexadecimal. Numeric references are useful when a named entity does not exist or when you need one character from a large set.

Why escaping is a security matter

If user input is inserted into a page without escaping, a visitor can type markup and have it run in other people's browsers. Escaping < and > turns that markup into harmless text. Escape at the point of insertion, for the context you insert into. Text in an HTML body, an attribute value and a URL each need different treatment.

Encoding and decoding

The HTML entities tool converts text to entities and back in your browser. Use it to check what a string looks like once it is escaped, or to read an entity-heavy export. Nothing you paste is uploaded.

A quick checklist

Written by Ján Turský

Creator of TextArray — building free, privacy-first tools that run entirely in your browser.