What are HTML Entities? How to Encode Special Characters for Web
Learn what HTML entities are, why they are essential for web development, and how to safely display reserved characters like &, <, and > on web pages.
In HTML, which forms the structural skeleton of web pages, certain characters are reserved by the browser for structural use. For instance, the < (less than) and > (greater than) characters are reserved because they open and close HTML tags.
If you want to display these characters as plain text on a web page, the browser might interpret them as code, which can break your layouts or cause rendering errors. To prevent this confusion, web developers use HTML Entities.
What is an HTML Entity?
An HTML Entity is a specialized string of characters that represents a reserved character or symbol. When the browser parses an HTML entity, it displays the corresponding character on the page instead of attempting to run it as code. An HTML entity always starts with an ampersand (&) and ends with a semicolon (;).
HTML entities can be represented in two ways:
- Entity Name: An easy-to-remember name (e.g.,
<). - Entity Number: The decimal or hexadecimal unicode value of the character (e.g.,
<).
Why Do We Need HTML Entities?
There are three primary reasons to encode text using HTML entities:
1. Displaying Reserved Characters
Characters like <, >, &, and " are syntactically meaningful in HTML. To write about HTML code on a web page safely (for example, displaying a <div> tag inside a tutorial), you must write it using entities, like <div>.
2. Rendering Non-breaking Spaces
Web browsers collapse multiple consecutive spaces into a single space. If you want to force multiple spaces in a row, you can use the non-breaking space entity .
3. Displaying Keyboard-inaccessible Characters
Symbols that may not be on standard keyboards, such as copyright (©), trademark (™), degree (°), or currency symbols (€, £), can be safely rendered on all browsers by using their respective HTML entity codes.
Commonly Used HTML Entities
Here are the most frequently used HTML entities in web development:
| Character | Description | Entity Name | Entity Number |
| :---: | :--- | :---: | :---: |
| < | Less than | < | < |
| > | Greater than | > | > |
| & | Ampersand | & | & |
| " | Double quote | " | " |
| ' | Single quote | ' | ' |
| | Non-breaking space | |   |
| © | Copyright | © | © |
Convert Text Instantly with our HTML Entity Encoder
Manually converting large code blocks or paragraphs containing special characters into HTML entities is slow and prone to copy-paste mistakes.
With our online HTML Entity Encoder/Decoder tool, you can paste your text and convert all special characters into HTML entities (or decode them back to readable characters) in a single click. The tool runs locally inside your browser, ensuring your source content remains secure.