Foundation • Bundle 1
Questions: HTML Entities
An HTML entity is a sequence of characters that altogether represent a single character in the final HTML output. It begins with an ampersand (&
) and ends with a semicolon (;
).
A character reference is basically just another name for an HTML entity.
- Named entities (which use names to refer to given characters, for e.g.
<
for the less-than,<
, symbol). - Numeric entities (which use numeric codes to refer to given characters).
A named entity is an HTML entity with a name. That simple! Some common examples are <
(less-than, <
), >
(greater-than, >
),
(non-breaking space), →
(right arrow, →
), •
(bullet point, •
), and so on and so forth.
denotes a non-breaking space in HTML.
The entities <
and >
represent the less-than (<
) and greater-than (>
) symbols in HTML, respectively. They are really common in HTML because otherwise representing <
and >
can mess up with actual markup (as <
represents the beginning of an HTML tag).
Since the desired text contains the <
character, which otherwise has a special meaning in HTML code (i.e. denotes an HTML tag's beginning), we must use the <
entity to denote it. Henceforth, the text '2 < 3' would be represented as follows:
2 < 3
&
.
A numeric entity is an HTML entity containing a numeric code corresponding to the character that the entity denotes. Its general form For example, the <
character corresponds to the numeric code 60 (in decimal). Likewise, we can denote it using the <
numeric entity.
A numeric entity can either be of the general form:
&#<code>;
, where<code>
denotes the numeric code corresponding to the character in decimal, or&#x<code>;
, where<code>
denotes the numeric code in hexadecimal.
Decimal numeric entity: F
. Hexadecimal numeric entity: F
.