Frequently Asked Questions
What are HTML entities?
HTML entities are special codes used to represent characters that have special meaning in HTML or cannot be typed directly. For example, < must be written as < so that browsers display it as a less-than sign rather than interpreting it as the start of an HTML tag. Common entities include & (&), < (<), > (>), " ("), and (non-breaking space).
When to use HTML entity encoding
Use HTML entity encoding when rendering user-generated content in HTML to prevent XSS (cross-site scripting) attacks. If a user inputs <script>, encoding it to <script> ensures the browser displays it as text rather than executing it as code. It is also useful when including HTML code examples in documentation.