HTML Entities
Master techniques for rendering protected characters and specialized glyphs within markup content
Protected HTML characters require entity substitution for proper display. Additionally, keyboard-unavailable characters become accessible through entity notation systems.
What are HTML Entities?
Some characters are reserved in HTML. If you use the less than (<) or greater than (>) signs in your text, the browser might mix them with tags.
Character entities are used to display reserved characters in HTML.
Entity Syntax
An entity can be written in two ways:
- Entity Name:
&entity_name; - Entity Number:
&#entity_number;
Example - Displaying Less Than Sign
<p>To display a less than sign, use < or <</p>
Result:
To display a less than sign, use < or <
Tip: Using entity names is easier to remember, but not all browsers support all entity names. However, entity numbers are supported by all browsers.
Non-breaking Space
A commonly used entity in HTML is the non-breaking space:
A non-breaking space is a space that will not break into a new line. Two words separated by a non-breaking space will stick together (not break into a new line).
Example - Non-breaking Space
<p>This is paragraph 1.</p>
<p>This is paragraph 2.</p>
Common Uses:
- Prevent line breaks between words (e.g., "10 km")
- Add multiple spaces (HTML normally collapses multiple spaces into one)
- Keep related items together (e.g., "Mr. Smith")
Common HTML Entities
Here are the most commonly used character entities in HTML:
Currency Symbols
Example - Currency Symbols
<p>The price is €50 or £43 or ¥5500</p>
Result:
The price is €50 or £43 or ¥5500
Mathematical Symbols
Example - Math Symbols
<p>5 × 3 = 15</p>
<p>10 ÷ 2 = 5</p>
<p>x ≠ 0</p>
Result:
5 × 3 = 15
10 ÷ 2 = 5
x ≠ 0
Other Common Symbols
Example - Common Symbols
<p>© 2025 My Company</p>
<p>HTML Free Codes®</p>
<p>The temperature is 25°C</p>
Result:
© 2025 My Company
HTML Free Codes®
The temperature is 25°C
Diacritical Marks
Diacritical marks (accents) are added to letters. Some diacritical marks are available as separate entities in HTML.
Example - Diacritical Marks
<p>Café is a French word.</p>
<p>He visited España (Spain).</p>
<p>Nürnberg is a city in Germany.</p>
Result:
Café is a French word.
He visited España (Spain).
Nürnberg is a city in Germany.
Combining Diacritical Marks
A combining character is a character that is placed on top of another character. These are called combining diacritical marks.
Example - Combining Marks
<p>à á â ã</p>
Result:
à á â ã
Practical Examples
Example - Displaying HTML Code
<p>To create a heading, use <h1>Your Heading</h1></p>
<p>The <p> tag defines a paragraph.</p>
Example - Legal and Copyright
<footer>
<p>© 2025 My Company®. All rights reserved.</p>
<p>Product Name™</p>
</footer>
Example - Scientific Notation
<p>E = mc<sup>2</sup></p>
<p>H<sub>2</sub>O</p>
<p>Temperature range: -10°C to 35°C</p>
Best Practices for Using Entities
✓ Tips
- Always use entities for reserved characters (<, >, &, ")
- Use entities for special characters not on your keyboard
- Entity names are easier to remember than numbers
- Entity numbers have better browser support
- Use UTF-8 charset to support most characters without entities
- Use
to prevent unwanted line breaks - Consider using Unicode directly if UTF-8 is enabled
HTML Free Codes