HTML Entities and Symbols
What are HTML Entities?
HTML entities are codes used to display special characters in HTML documents. Certain characters have special meaning in HTML (such as <, >, and &), and if you want to display these characters on a page, you need to use HTML entities.
Entity Syntax
HTML entities can be represented in two ways:
- Entity name:
&entity_name; - Entity number:
&#entity_number;
For example:
<or<represents<>or>represents>
Reserved Characters
Characters That Must Use Entities
Example
Display result:
Space Characters
Common Symbols
Currency Symbols
Mathematical Symbols
Greek Letters
Arrow Symbols
Punctuation Symbols
Quotation Marks
Other Common Symbols
Emoji Symbols
Modern browsers support Unicode emoji:
Practical Examples
Copyright Notice
Mathematical Formulas
Price Display
Quoted Text
Complete Example
Best Practices
- Use UTF-8 encoding: Use
<meta charset="UTF-8">in HTML documents to directly input most special characters - Escape reserved characters: Always use entities for
<,>,&,", etc. - Improve readability: For common symbols, entity names are more readable than numbers
- Consider compatibility: Some older browsers may not support all entities
- Use semantic symbols: Use appropriate symbols in the right places (e.g., copyright, trademark symbols)
Summary
HTML entities are an important tool for displaying special characters on webpages. Mastering common HTML entities can help you create more professional and accurate webpage content. Remember to escape reserved characters and use appropriate symbols and characters as needed.