In SGML, HTML and XML documents, the logical constructs known as character data and attribute values consist of sequences of characters, in which each character can manifest directly (representing itself), or can be represented by a series of characters called a character reference, of which there are two types: a numeric character reference and a character entity reference. This article lists the character entity references that are valid in HTML and XML documents.
A character entity reference refers to the content of a named entity. An entity declaration is created in XML, SGML and HTML documents (before HTML5) by using the <!ENTITY name "value">
syntax in a Document type definition (DTD).
In HTML and XML, a numeric character reference refers to a character by its Universal Character Set/Unicode code point, and uses the format:
&#x''hhhh'';
or
&#''nnnn'';
where the x
must be lowercase in XML documents, hhhh is the code point in hexadecimal form, and nnnn is the code point in decimal form. The hhhh (or nnnn) may be any number of hexadecimal (or decimal) digits and may include leading zeros. The hhhh for hexadecimal digits may mix uppercase and lowercase letters, though uppercase is the usual style. However the XML and HTML standards restrict the usable code points to a set of valid values, which is a subset of UCS/Unicode code point values, that excludes all code points assigned to non-characters or to surrogates, and most code points assigned to C0 and C1 controls (with the exception of line separators and tabulations treated as white spaces).
In contrast, a character entity reference refers to a sequence of one or more characters by the name of an entity which has the desired characters as its replacement text. The entity must either be predefined (built into the markup language), or otherwise explicitly declared in a Document Type Definition (DTD) (see). The format is the same as for any entity reference:
&''name'';
where name is the case-sensitive name of the entity. The semicolon is usually required in the character entity reference, unless marked otherwise in the table below (see).
&amp;
, &lt;
, &gt;
, &apos;
, and &quot;
. The trailing semicolon is mandatory in XML (and XHTML) for these five entities (even if HTML or SGML allows omitting it for some of them, according to their DTD).Numerous other entity sets have been developed for special requirements, and for major and minority scripts. However, the advent of Unicode has largely superseded them.
The full formal public identifier and system identifier for the DTD entities subset (where the character entity name is defined) is actually mapped from one of the following three defined named entities:
Name | Version | Formal public identifier | System identifier | |
---|---|---|---|---|
HTMLlat1 | HTML 4 | "-//W3C//ENTITIES Latin 1//EN//HTML" | "<span class="plainlinks">http://www.w3.org/TR/html4/HTMLlat1.ent</span>" (optional) | |
XHTML 1 | "-//W3C//ENTITIES Latin 1 for XHTML//EN" | "<span class="plainlinks">http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent</span>" | ||
HTMLsymbol | HTML 4 | "-//W3C//ENTITIES Symbols//EN//HTML" | "<span class="plainlinks">http://www.w3.org/TR/html4/HTMLsymbol.ent</span>" (optional) | |
XHTML 1 | "-//W3C//ENTITIES Symbols for XHTML//EN" | "<span class="plainlinks">http://www.w3.org/TR/xhtml1/DTD/xhtml-symbol.ent</span>" | ||
HTMLspecial | HTML 4 | "-//W3C//ENTITIES Special//EN//HTML" | "<span class="plainlinks">http://www.w3.org/TR/html4/HTMLspecial.ent</span>" (optional) | |
XHTML 1 | "-//W3C//ENTITIES Special for XHTML//EN" | "<span class="plainlinks">http://www.w3.org/TR/xhtml1/DTD/xhtml-special.ent</span>" | ||
html.dtd | N/A | "<span class="plainlinks">http://info.cern.ch/MarkUp/html-spec/html.dtd</span>" | ||
HTML 5 | "-//W3C//ENTITIES HTML MathML Set//EN//XML" | "<span class="plainlinks">http://www.w3.org/2003/entities/2007/htmlmathml-f.ent</span>" |
The ISO entities subsets are old (documented) character subsets, which are given SGML character entity names in ISO 8879 and ISO 9573, and which were used in legacy encodings before the unification within ISO 10646. Their full formal public identifiers are as follows:
Name | Formal public identifier(s) | |
---|---|---|
ISOamsa | ||
ISOamsb | ||
ISOamsc | ||
ISOamsn | ||
ISOamso | ||
ISOamsr | ||
ISObox | ||
ISOchem | ||
ISOcyr1 | ||
ISOcyr2 | ||
ISOdia | ||
ISOgrk1 | ||
ISOgrk2 | ||
ISOgrk3 | ||
ISOgrk4 | ||
ISOlat1 | ||
ISOlat2 | ||
ISOmfrk | ||
ISOmopf | ||
ISOmscr | ||
ISOnum | ||
ISOpub | ||
ISOtech |
HTML5 defines many named entities, references to which act as mnemonic aliases for certain Unicode characters.[1] The HTML5 specification does not allow users to define additional entities, as it no longer accepts any DTD to be referenced or extended inside HTML documents (this is still needed in XHTML, which is based on stricter XML parsing rules but allows referencing or defining a DTD in the document header, because XML does not predefine most HTML entities).
In the below table, the "Standard" column indicates the first version of the HTML DTD that defines the character entity reference, and indicates characters that are predefined in XML without needing any DTD. To use one of these character entity references in an HTML or XML document, enter an ampersand (&) followed by the entity name, and a semicolon (mandatory in XML, and strongly recommended in HTML for all entities, even if HTML allows omitting the semicolon only from some entities indicated below by), e.g., enter &copy;
for the copyright symbol .
There are no predefined character entities in HTML for characters or sequences of most scripts encoded in the UCS (except a common subset of whitespace, punctuation, mathematical or technical symbols, currency symbols, a few Hebrew symbols used in mathematical notations, and the most common letters in Latin, Greek or Cyrillic). Note also that not all bidirectional controls defined in UCS/Unicode are represented as standard character entities in HTML (not even in HTML5, which defines more general directional elements and attributes for that purpose). Notably, there are no predefined HTML character entities for controls that were added in the UCS/Unicode and formally defined in version 2 of the Unicode Bidi Algorithm.
Most entities are predefined in XML and HTML to reference just one character in the UCS, but there are no predefined entities for isolated combining characters, variation selectors, or characters for private use assignments; however the list includes some predefined entities for character sequences of two characters containing some of them. Since HTML 5.0 (and MathML 3.0 which shares the same set en entities), all entities are encoded in Unicode normalization forms C and KC (this was not the case with older versions of HTML and MathML, so older entities that were initially defined with characters for private use assignments, CJK compatibility forms, or in non-NFC forms were modified[2]).
However, all valid characters and sequences in the UCS, including all bidirectional controls or private-use assignments (but with the exception of non-whitespace C0 and C1 controls, non-characters, and surrogates) are also usable and valid in HTML, XML, XHTML and MathML, either in plain-text values of attributes or in text elements (by encoding them directly as plain text, or using numeric character references when needed).
Entities | Codepoints | Standard | DTD | Old ISO subset | Description | |||
---|---|---|---|---|---|---|---|---|
data-sort-value=" " | TAB | data-sort-value="0:0:0:0:0:9" | U+0009 | HTML 5.0 | character tabulation (TAB) | |||
data-sort-value=" " | LF | data-sort-value="0:0:0:0:0:A" | U+000A | HTML 5.0 | line feed (LF) | |||
̑ | data-sort-value="0:0:0:0:2:0 0:0:0:3:1:1" | U+0020 U+0311 U+0311 | combining inverted breve (combining down breve) | |||||
⃛ | data-sort-value="0:0:0:0:2:0 0:0:2:0:D:B" | U+0020 U+20DB U+20DB | combining three dots above | |||||
⃜ | data-sort-value="0:0:0:0:2:0 0:0:2:0:D:C" | U+20DC | combining four dots above | |||||
! | data-sort-value="0:0:0:0:2:1" | U+0021 | HTML 5.0 | ISOnum | exclamation mark | |||
" | data-sort-value="0:0:0:0:2:2" | U+0022 | html.dtd HTMLspecial | ISOnum | quotation mark | |||
data-sort-value="0:0:0:0:2:3" | U+0023 | HTML 5.0 | ISOnum | number sign | ||||
$ | data-sort-value="0:0:0:0:2:4" | U+0024 | HTML 5.0 | ISOnum | dollar sign | |||
% | data-sort-value="0:0:0:0:2:5" | U+0025 | HTML 5.0 | ISOnum | percent sign | |||
& | data-sort-value="0:0:0:0:2:6" | U+0026 | html.dtd HTMLspecial | ISOnum | ampersand | |||
' | data-sort-value="0:0:0:0:2:7" | U+0027 | XML 1.0 | HTMLspecial | ISOnum | apostrophe (apostrophe-quote); see below | ||
( | data-sort-value="0:0:0:0:2:8" | U+0028 | HTML 5.0 | ISOnum | left parenthesis | |||
) | data-sort-value="0:0:0:0:2:9" | U+0029 | HTML 5.0 | ISOnum | right parenthesis | |||
data-sort-value="0:0:0:0:2:A" | U+002A | HTML 5.0 | ISOnum | asterisk (middle asterisk) | ||||
+ | data-sort-value="0:0:0:0:2:B" | U+002B | HTML 5.0 | ISOnum | plus sign | |||
, | data-sort-value="0:0:0:0:2:C" | U+002C | HTML 5.0 | ISOnum | comma | |||
. | data-sort-value="0:0:0:0:2:E" | U+002E | HTML 5.0 | ISOnum | full stop (period) | |||
/ | data-sort-value="0:0:0:0:2:F" | U+002F | HTML 5.0 | ISOnum | solidus | |||
data-sort-value="0:0:0:0:3:A" | U+003A | HTML 5.0 | ISOnum | colon | ||||
data-sort-value="0:0:0:0:3:B" | U+003B | HTML 5.0 | ISOnum | semicolon | ||||
< | data-sort-value="0:0:0:0:3:C" | U+003C | html.dtd HTMLspecial | ISOnum | less-than sign | |||
<⃒ | data-sort-value="0:0:0:0:3:C 0:0:2:0:D:2" | U+003C U+20D2 | HTML 5.0 | ISOamsn | less-than sign, combining long vertical line overlay | |||
= | data-sort-value="0:0:0:0:3:D" | U+003D | HTML 5.0 | ISOnum | equals sign | |||
=⃥ | data-sort-value="0:0:0:0:3:D 0:0:2:0:E:5" | U+003D U+20E5 | HTML 5.0 | ISOtech | equals sign, combining reverse solidus overlay | |||
> | data-sort-value="0:0:0:0:3:E" | U+003E | html.dtd HTMLspecial | ISOnum | greater-than sign | |||
>⃒ | data-sort-value="0:0:0:0:3:E 0:0:2:0:D:2" | U+003E U+20D2 | HTML 5.0 | ISOamsn | greater-than sign, combining long vertical line overlay | |||
? | data-sort-value="0:0:0:0:3:F" | U+003F | HTML 5.0 | ISOnum | question mark | |||
@ | data-sort-value="0:0:0:0:4:0" | U+0040 | HTML 5.0 | ISOnum | commercial at | |||
[| data-sort-value="0:0:0:0:5:B" | [[Basic Latin (Unicode block)|U+]]005B| HTML 5.0| | ISOnum| left square bracket (left bracket)|-| | \| data-sort-value="0:0:0:0:5:C" | U+005C| HTML 5.0| | ISOnum| reverse solidus (backward solidus)|-| | ] | data-sort-value="0:0:0:0:5:D" | U+005D | HTML 5.0 | ISOnum | right square bracket (right bracket) | |||
^ | data-sort-value="0:0:0:0:5:E" | U+005E | HTML 5.0 | circumflex accent (hat) | ||||
_ | data-sort-value="0:0:0:0:5:F" | U+005F | HTML 5.0 | ISOnum | low line (low bar; &underbar) | |||
` | data-sort-value="0:0:0:0:6:0" | U+0060 | HTML 5.0 | ISOdia | grave accent (diacritical grave) | |||
fj | data-sort-value="0:0:0:0:6:6 0:0:0:0:6:A" | U+0066 U+006A | HTML 5.0 | ISOpub | latin small letter f, latin small letter j | |||