The Developer's Guide to HTML Entities: Escaping Special Characters
Why < and > Break HTML
HTML uses the less-than (<) and greater-than (>) symbols to define tags like <div>. If you try to display these characters as plain text on your webpage, the browser gets confused and tries to interpret them as code. This often breaks your layout or, worse, leads to security vulnerabilities. Use our HTML Entity Encoder to handle this automatically.
The Security Risk: XSS
Cross-Site Scripting (XSS) is a major attack vector where hackers inject malicious scripts into your site via comments or forms. If you don't 'escape' (encode) user input, a hacker could input <script>stealCookies()</script>, and your site would execute it. Our encoder converts these dangerous characters into safe text strings, neutralizing the threat before it reaches your users.
Common Entities You Should Know
- < becomes
< - > becomes
> - & becomes
& - " becomes
"
Named vs. Numeric Entities
There are two ways to represent a character in HTML:
- Named Entity: Easier to remember and read. E.g.,
© for ©. - Numeric Entity: Using the ASCII/Unicode code. E.g.,
© (Decimal) or © (Hex). These are useful if a specific named entity isn't supported or if you are working with less common characters.
Related Security Tools