HTML Entities
HTML entities represent reserved or special characters that would otherwise be interpreted as code, like < and >, or characters not easily typed, like © or é.
Entities start with an ampersand (&) and end with a semicolon (;), and come in named form (©) or numeric form (©).
&entityname; or &#code;Why entities are needed
Characters like < and > have special meaning in HTML syntax. Writing them literally could be misinterpreted as the start of a tag, so entities like < and > are used instead.
Named vs numeric entities
Named entities are easier to read (& for &). Numeric entities (&) work for any Unicode character, even ones without a common name.
<p>5 < 10 and 10 > 5</p>5 < 10 and 10 > 5< and > display literal less-than and greater-than symbols.
<p>© 2024 MyCompany. Café is open.</p>© 2024 MyCompany. Café is open.© and é render special typographic characters.
Key points
- Entities start with & and end with ;.
- < and > escape < and > characters.
- & escapes the ampersand itself.
- Numeric entities (&#code;) work for any Unicode character.
