HTML entities are used as a replacement of reserved characters in HTML. Some characters are reserved in HTML and they have special meaning when used in HTML.
For example, you cannot use the greater than(<) or less than(>) in your HTML document because the browser will treat them differently.
The characters that are either reserved for HTML or not present on the keyboard are called reserved characters.
The character entity looks like this.
&entity_name;
OR
entity_number;
Non-breaking Space:
Most commonly used character entity in HTML is the non-breaking space i.e .
The non-breaking space is used to create a space in a line that cannot be broken by word wrap.
The allows you to create multiple spaces that are visible on a web page and not only in the source code.
The words separated by non-breaking space will not break into a new line.
For Example:
$ 20, 20 min/sec, 11 AM
If you write 5 spaces in your text then the browser will remove an additional 4 spaces from your text.
If you want to add multiple spaces to your text then you can use the character entity.
Some Useful HTML Character Entities:
Symbol | Description | Entity Name | Entity Number |
---|---|---|---|
non-breaking space | |   | |
< | less than | < | < |
> | greater than | > | > |
& | ampersand | & | & |
" | double quotation mark | " | " |
' | single quotation mark(apostrophe) | ' | ' |
¢ | cent | ¢ | ¢ |
£ | pound | £ | £ |
¥ | yen | ¥ | ¥ |
€ | euro | € | € |
© | copyright | © | © |
® | registered trademark | ® | ® |
™ | trademark | ™ | ™ |
§ | section | § | § |
¦ | broken vertical bar | ¦ | ¦ |
Note: Entity names in HTML are case sensitive.
Diacritical Marks:
The special subtype of character entity code that is used to give particular value, to indicate stress.
These marks appear directly over the preceding letter and accent marks and tildes.
Some Diacritical Marks:
Mark | Character | Construct | Result |
---|---|---|---|
̀ | a | à | à |
́ | a | á | á |
̂ | a | â | â |
̃ | a | ã | ã |
̀ | O | Ò | Ò |
́ | O | O& #769; | Ó |
̂ | O | Ô | Ô |
̃ | O | O& #771; | Õ |
HTML Symbol Entities:
Different types of mathematical, currency and technical symbols are not present on the keyboard.
To add those symbols to your HTML document you can use an HTML entity name.
If an entity name does not exist, you can use an entity number or hexadecimal reference.
Example:
<p> This will display as £ </p>
<p> This will display as £ </p>
<p> This will display as £ </p>
Mathematical Symbols Supported by HTML:
Character | Description | Number | Entity |
---|---|---|---|
∀ | for all | ∀ | ∀ |
∅ | empty sets | ∅ | ∅ |
∃ | there exists | ∃ | ∃ |
∂ | partial differential | ∂ | ∂ |
∋ | contains as a member | ∋ | ∋ |
∉ | not an element of | ∉ | ∉ |
∈ | element of | ∈ | ∈ |
∇ | nabla | ∇ | ∇ |
Greek Letters Supported by HTML:
Character | Description | Number | Entity |
---|---|---|---|
Α | capital letter alpha | Α | Α |
Β | capital letter beta | Β | Β |
Γ | capital letter gamma | Γ | Γ |
Δ | capital letter delta | Δ | Δ |
Ε | capital letter epsilon | Ε | Ε |
Ζ | capital letter zeta | Ζ | Ζ |
Some Other Entities Supported by HTML:
Character | Description | Number | Entity |
---|---|---|---|
← | leftwards arrow | ← | ← |
↑ | upwards arrow | ↑ | ↑ |
→ | rightwards arrow | → | → |
↓ | downwards arrow | ↓ | ↓ |
♠ | black spade suit | ♠ | ♠ |
♣ | black club suit | ♣ | ♣ |
♥ | black heart suit | ♥ | ♥ |
♦ | black diamond suit | ♦ | ♦ |