What Are HTML Entities?
HTML entities allow you to represent characters that have special meaning in HTML or that might not be displayable in the document's character encoding. The ampersand (&) starts an entity; the semicolon (;) ends it. Between them you have either a name (amp, lt, gt, copy, nbsp) or a numeric code (& for decimal, & for hex).
Every HTML parser must decode these five named entities: & < > " '. Hundreds more named entities exist for common symbols (©, ®, ™, €, etc.). Numeric entities can represent any Unicode character.
When to Encode HTML
Encode user-generated content before inserting it into HTML to prevent XSS (cross-site scripting). If you display "<script>alert(1)</script>" without encoding, it could execute. Encoded as <script>alert(1)</script>, it displays safely as text. Encode when building HTML strings in code, when storing content for web display, or when passing data to templates. Use 'encode required only' for minimal encoding, or 'encode all' when you need maximum compatibility.
Named vs Numeric Entities
Named entities like © (©) and ™ (™) are human-readable and shorter for common characters. Numeric decimal (©) and hex (©) work for every character. Hex is often used for characters without named entities. In XML, only numeric entities are guaranteed; named entities depend on the DTD. For maximum portability, numeric hex entities are a safe choice.
Common HTML Entity Reference
Essential: & < > " '. Common symbols: (non-breaking space), © (©), ® (®), ™ (™), — (—), – (–), • (•), … (…), ‘ ’ (curly quotes), “ ” (curly double quotes). Math: × ÷ ± −. Currency: € £ ¥ ¢. Greek: α β γ Δ π Ω. Use the reference table in the tool for quick lookup.
Frequently Asked Questions
Related Tools
Explore More Tools
Find this tool useful? Buy us a coffee to keep DuskTools free and ad-light.