Entities
Entities are character sequences placed in the text of an HTML document to print out reserved characters which may otherwise be interpreted as HTML code by a browser, or other special characters that would be difficult to generate with a typical keyboard. In fact, using reference numbers, an entity can represent any Unicode character. When parsing the HTML, a browser replaces the entity’s character sequence with the character it represents.
Syntax
Entities are case-sensitive and can take one of three forms.
The first form references an entity by name:
&name;
The second form references it by the decimal Unicode number:
&#number;
The third represents it with the hexadecimal Unicode number, often with leading zeros:
&#xnumber;
So the copyright entity (©
) can be represented as ©
, ©
or ©
.
Entity Values
There are many HTML entities. The following are some common ones:
Entity Name | 1st Form | 2nd Form | 3rd Form |
---|---|---|---|
Non-breaking space | |
  |
  |
Less-than sign < |
< |
< |
< |
Greater-than sign > |
> |
> |
> |
Ampersand & |
& |
& |
& |
Quote " |
" |
" |
" |
Apostrophe ' |
' |
' |
' |
Copyright © |
© |
© |
© |
Degree ° |
° |
° |
° |
Euro € |
€ |
€ |
€ |
Bullet character • |
• |
• |
• |
More can be found in this extensive HTML 5 entity reference.
The Tab Entity
There is an entity 	
(or 	
) which nominally produces a tab character. However, it will not behave as expected because HTML collapses whitespace where it appears in text with the exception of the non-breaking space entity,
. So to render a tab in HTML text, it needs to be wrapped within a <pre>
tag to preserve the whitespace.
<p>The tab entity 	 in this sentence is collapsed.</p><pre><p>The tab entity 	 in this sentence is preserved.</p></pre>
Output:
Alternatively, four
entities can be used.
<p>The Tab entity 	 in this sentence is collapsed.</p><p>The spaces in this sentence are preserved.</p>
Entities
- Greek Symbols
- Used in scientific, mathematical, and technological applications.
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.