Understanding HTML Entities & Reserved Character Security
<, >, &, and " to define tag structures and attributes. Displaying raw user input containing these characters directly in HTML causes tag parsing errors or introduces severe Cross-Site Scripting (XSS) security vulnerabilities. HTML entities convert reserved characters into safe character reference codes that browsers render as visible text without executing as HTML code.<!-- Raw Text Input -->
<script>alert("XSS")</script>
<!-- HTML Entity Encoded Output -->
<script>alert("XSS")</script>- Named entities: Short text mnemonics (e.g. `<` for `<`, `&` for `&`)
- Decimal entities: Base-10 ASCII/Unicode code points (e.g. `<` for `<`)
- Hexadecimal entities: Base-16 Unicode references (e.g. `<` for `<`)
- Neutralizes malicious script tag injections when echoing dynamic data