What is HTML Entity?
HTML Entity (HTML Character Entity) is a string that begins with an ampersand (&) and ends with a semicolon (;), used to represent special characters in HTML that would otherwise be interpreted as HTML code or are not easily typed on a keyboard.
Quick Facts
| Full Name | HTML Character Entity |
|---|---|
| Created | 1993 (with HTML specification) |
| Specification | Official Specification |
How HTML Entity Works
HTML entities allow web developers to display reserved characters like <, >, &, and " that have special meanings in HTML markup. They also enable the display of characters not available on standard keyboards, such as copyright symbols (©), mathematical symbols (±), and characters from other languages. Entities can be written as named references (like &) or numeric references using decimal (&) or hexadecimal (&) codes. The HTML5 specification defines over 2,000 named character references.
Key Characteristics
- Starts with & and ends with ; (e.g., &)
- Named entities use descriptive names (e.g., ©)
- Numeric entities use decimal (©) or hex (©) codes
- Required for displaying reserved HTML characters
- Case-sensitive for named entities
- Over 2,000 named entities defined in HTML5
Common Use Cases
- Displaying HTML reserved characters (<, >, &, ", ')
- Inserting special symbols (©, ®, ™, €)
- Adding non-breaking spaces ( )
- Displaying mathematical symbols (±, ×, ÷)
- Including characters from other languages
Example
<!-- Reserved Characters -->
< = < (less than)
> = > (greater than)
& = & (ampersand)
" = " (double quote)
' = ' (apostrophe)
<!-- Common Symbols -->
© = © (copyright)
® = ® (registered)
™ = ™ (trademark)
= (non-breaking space)
<!-- Numeric Entities -->
© = © (decimal)
© = © (hexadecimal)
<!-- Usage in HTML -->
<p>5 < 10 && 10 > 5</p>