HTML Entities: Named and Numeric References
Named entities are readable
In HTML source, write © to display ©. The source text starts with an ampersand, uses the name copy, and ends with a semicolon; the browser decodes it while parsing markup. In an HTML editor that already escapes input, paste © instead of double-encoding the ampersand.
Use & for a literal ampersand and < for a literal less-than sign in HTML text. inserts a non-breaking space, which prevents a line break and is not interchangeable with an ordinary space. See the ampersand character record for its Unicode and URL encodings.
Numeric entities use code points
In HTML source, © is decimal and © is hexadecimal. Both decode to © (U+00A9), the same result as ©. The number is the Unicode code point, not a UTF-8 byte value.
Numeric references can express Unicode characters even without a named reference. For example, — represents an em dash. Use the HTML entity directory to check which named references actually exist; do not invent a name from a Unicode character name.
When escaping matters
For HTML text nodes, escape & and < before inserting untrusted data. In quoted attribute values, escape the matching quotation mark too. Use a context-aware encoder or DOM textContent for user input; replacing a few characters by hand is insufficient for JavaScript, CSS, and URL contexts.
A slash / is ordinary text in HTML and does not need a character reference. In URL paths it separates segments, while its percent-encoded form is %2F; see the slash character record before copying an encoding across contexts.