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.
Character reference overview In HTML and XML, a numeric character reference refers to a character by its Universal Coded Character Set/Unicode code point, and uses the format: or where the x must be lowercase in XML documents, is the code point in hexadecimal form and is the code point in decimal form. The (or ) may be any number of hexadecimal (or decimal) digits and may include leading zeros. The for hexadecimal digits may mix uppercase and lowercase letters, though uppercase is the usual style. 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).
By 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 format is: where 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 ). The entity must either be predefined (built into the markup language), or declared in a Document Type Definition (DTD) by using <!ENTITY name "value">.
Standard public entity sets for characters XML XML specifies five predefined entities needed to support every printable ASCII character: &, <, >, ', and ". 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). ISO Entity Sets SGML supplied a comprehensive set of entity declarations for characters widely used in Western technical and reference publishing, for Latin, Greek and Cyrillic scripts. The American Mathematical Society also contributed entities for mathematical characters (see ). HTML Entity Sets Early versions of HTML built in small subsets of these, relating to characters found in three Western 8-bit character sets. MathML Entity Sets The W3C developed a set of entity declarations for MathML characters. XML Entity Sets The W3C MathML Working Group took over maintenance of the ISO public entity sets, combined with the MathML and documents them in XML Entity Definitions for Characters. This set can support the requirements of XHTML, MathML and as an input to future versions of HTML. HTML5 HTML5 adopts the XML entities as named character references, and does not group them into sets. The character reference names originate from XML Entity Definitions for Characters. The HTML5 specification additionally provides mappings from the names to Unicode character sequences using JSON.
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.
Formal public identifiers for HTML DTD entities subsets 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:
+ HTML DTD entities subsets Name Version Formal public identifier System identifier HTMLlat1 HTML 4 "-//W3C//ENTITIES Latin 1//EN//HTML""http://www.w3.org/TR/html4/HTMLlat1.ent" (optional) XHTML 1 "-//W3C//ENTITIES Latin 1 for XHTML//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent" HTMLsymbol HTML 4 "-//W3C//ENTITIES Symbols//EN//HTML""http://www.w3.org/TR/html4/HTMLsymbol.ent" (optional) XHTML 1 "-//W3C//ENTITIES Symbols for XHTML//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml-symbol.ent" HTMLspecial HTML 4 "-//W3C//ENTITIES Special//EN//HTML""http://www.w3.org/TR/html4/HTMLspecial.ent" (optional) XHTML 1 "-//W3C//ENTITIES Special for XHTML//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml-special.ent" html.dtd N/A"http://info.cern.ch/MarkUp/html-spec/html.dtd" HTML 5 "-//W3C//ENTITIES HTML MathML Set//EN//XML" "http://www.w3.org/2003/entities/2007/htmlmathml-f.ent"
Formal public identifiers for old ISO entities subsets 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:
+ ISO entities subsets 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
List of character entity references in HTML HTML5 defines many named entities, references to which act as mnemonic aliases for certain Unicode characters. 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 © 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).
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).