In
SGML
The Standard Generalized Markup Language (SGML; ISO 8879:1986) is a standard for defining generalized markup languages for documents. ISO 8879 Annex A.1 states that generalized markup is "based on two postulates":
* Declarative: Markup should des ...
,
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
syntax in a Document Type Definition (DTD).
Character reference overview
A
numeric character reference refers to a character by its
Universal Character Set/
Unicode ''code point'', and uses the format:
:''nnnn'';
or
:''hhhh'';
where ''nnnn'' is the code point in
decimal
The decimal numeral system (also called the base-ten positional numeral system and denary or decanary) is the standard system for denoting integer and non-integer numbers. It is the extension to non-integer numbers of the Hindu–Arabic numeral ...
form, and ''hhhh'' is the code point in
hexadecimal
In mathematics and computing, the hexadecimal (also base-16 or simply hex) numeral system is a positional numeral system that represents numbers using a radix (base) of 16. Unlike the decimal system representing numbers using 10 symbols, hexa ...
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
A document type definition (DTD) is a set of ''markup declarations'' that define a ''document type'' for an SGML-family markup language ( GML, SGML, XML, HTML).
A DTD defines the valid building blocks of an XML document. It defines the document ...
(DTD). The format is the same as for any entity reference:
:&''name'';
where ''name'' is the case-sensitive name of the entity. The semicolon is required, unless marked otherwise in the table below (see
).
Standard public entity sets for characters
; ISO Entity Sets:
SGML
The Standard Generalized Markup Language (SGML; ISO 8879:1986) is a standard for defining generalized markup languages for documents. ISO 8879 Annex A.1 states that generalized markup is "based on two postulates":
* Declarative: Markup should des ...
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.
; HTML Entity Sets: Early versions of
HTML built in small subsets of these, relating to characters found in three Western 8-bit fonts.
; 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 i
XML Entity Definitions for Characters This set can support the requirements of
XHTML,
MathML and as an input to future versions of HTML.
; HTML 5:
HTML5 adopts the XML entities a
named character references however it restates them without reference to their sources and does not group them into sets. The HTML 5 specification additionally provides mappings from the names to Unicode character sequences using
JSON
JSON (JavaScript Object Notation, pronounced ; also ) is an open standard file format and data interchange format that uses human-readable text to store and transmit data objects consisting of attribute–value pairs and arrays (or other ser ...
.
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.
List of predefined entities in XML
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.
List of character entity references in HTML
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 , a ''hexadecimal number'' and a ''semicolon''. For example, to display the copyright symbol , enter
©
or
©
. (When using this method, use the hexadecimal numbers in the third column, without the prefix
U+
.)
;Notes
Entities representing special characters in XHTML
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:
* If the document is read by a conforming HTML processor, then only the 252 HTML character entities can safely be used. The use of
'
or custom entity references may not be supported and may produce unpredictable results.
* If the document is read by an XML
parser that does not or cannot read external entities, then only the five built-in XML character entities (
see above) can safely be used, although other entities may be used if they are declared in the internal DTD subset.
* If the document is read by an XML parser that does read external entities, then the five built-in XML character entities can safely be used. The other 248 HTML character entities can be used as long as the XHTML DTD is accessible to the parser at the time the document is read. Other entities may also be used if they are declared in the internal DTD subset.
Because of the special
'
case mentioned above, only
"
,
&
,
<
, and
>
will work in all XHTML processing situations.
See also
*
Character encodings in HTML
*
Digraph and
Trigraph, a similar concept to enter unavailable characters
*
Escape character
In computing and telecommunication, an escape character is a character (computing), character that invokes an alternative interpretation on the following characters in a character sequence. An escape character is a particular case of metacharac ...
*
HTML decimal character rendering
*
Percent-encoding, used in URLs
*
SGML entity
References
{{Reflist
Further reading
Unicode Consortium See also:
Unicode Consortium
*
UnicodeData.txt from the Unicode ConsortiumWorld Wide Web Consortium See also:
World Wide Web Consortium
*
XML 1.0 spec*
*
HTML 3.2 spec*
HTML 4.0 spec*
HTML 4.01 spec*
HTML 5 spec*
XHTML 1.0 spec*
XML Entity Definitions for Characters* The normative reference to RFC 2070 (still found in DTDs defining the character entities for HTML or XHTML) is historic; this RFC (along with other RFC's related to different part of the HTML specification) has been deprecated in favor of the newer informational RFC 2854 which defines the "text/html" MIME type and references directly the W3C specifications for the actual HTML content.
*
Numerical Reference of Unicode code points at Wikibooks
W3 HTML5 Character Reference Chart
External links
at the W3C
XML and HTML character entity references
HTML
XML
Unicode