List of XML and HTML character entity references
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 by using the
<!ENTITY name "value"> syntax in a Document Type Definition (DTD).
where nnnn is the code point in decimal form, and hhhh is the code point in hexadecimal form. The x must be lowercase in XML documents. The nnnn or hhhh may be any number of digits and may include leading zeros. The hhhh may mix uppercase and lowercase, though uppercase is the usual style.
In contrast, a character entity reference refers to a character by the name of an entity which has the desired character as its replacement text. The entity must either be predefined (built into the markup language) or explicitly declared in a Document Type Definition (DTD). The format is the same as for any entity reference:
where name is the case-sensitive name of the entity. The semicolon is required, unless marked otherwise in the table below (see [a]).
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 XML specification does not use the term "character entity" or "character entity reference". The XML specification defines five "predefined entities" representing special characters, and requires that all XML processors honor them. The entities can be explicitly declared in a DTD, as well, but if this is done, the replacement text must be the same as the built-in definitions. XML also allows other named entities of any size to be defined on a per-document basis.
The table below lists the five XML predefined entities. The initial "Name" column mentions the entity's name. The "Character" column shows the character. To render the character, the format
&name; is used; for example,
& renders as &. The "Unicode code point" column cites the character via standard UCS/Unicode "U+" notation, which shows the character's code point in hexadecimal. The decimal equivalent of the code point is then shown in parentheses. The "Standard" column indicates the first version of XML that includes the entity. The final "Name" column cites the character via its canonical UCS/Unicode name.
The HTML 5 DTDs define many named entities, references to which act as mnemonic aliases for certain Unicode characters. The HTML 5 specification requires the use of the standard DTDs and does not allow users to define additional entities.
In the table below, the "Standard" column indicates the first version of the HTML DTD that defines the character entity reference. 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, e.g., enter
© for the copyright symbol (©).
Alternatively, enter an ampersand, followed by a number sign, a number and a semicolon. For example, to display the copyright symbol ©, enter
© (When using this method, use the parenthesized decimal numbers in the third column.) Equivalently, you can enter an ampersand, followed by a number sign, the letter x, a hexadecimal number and a semicolon. For example, to display the copyright symbol © enter
©. (When using this method, use the hexadecimal numbers in the third column, without the prefix
The XHTML DTDs explicitly declare 253 entities (including the 5 predefined entities of XML 1.0) whose expansion is a single character, which can therefore be informally referred to as "character entities". These (with the exception of the
' entity) have the same names and represent the same characters as the 252 character entities in HTML. Also, by virtue of being XML, XHTML documents may reference the predefined
' entity, which is not one of the 252 character entities in HTML 4. Additional entities of any size may be defined on a per-document basis. However, the usability of entity references in XHTML is affected by how the document is being processed:
Because of the special
' case mentioned above, only
> will work in all processing situations.