HTML Character entities are escape sequences that work in the HTML source domain. The character entities have a defined format that begins with an ampersand as a control sequence introducer and terminates with a semi-colon. The value between them is the character description.
Many of these have symbolic names which browsers honor to a greater or lesser extent depending on the browser and its vintage. HTML 4.0 defines a large number of these escaped entities. If the character you wish to represent does not have a symbolic name, you can use the decimal value of the character and then place a hash symbol in-front. You can also use the hexadecimal notation by placing an x in front of the value. Thus:
< defines the less-than or < symbol.
' defines a single quote or apostrophe character.
' also defines a single quote character.
Here is a table of useful character entity values:
Numeric | Named | Description | Netscape | MSIE |
 | - | - | Missing | Space |
 | - | - | Missing | Space |
 | - | - | Missing | Space |
 | - | - | Missing | Space |
 | - | - | Missing | Space |
 | - | - | Missing | Space |
 | - | - | Invisible | Space |
 | - | - | Missing | Space |
	 | - | Horizontal tab | Space | Space |

 | - | Line feed | Space | Space |
 | - | - | Space | Space |
 | - | - | Space | Space |

 | - | Carriage return | Space | Space |
 | - | - | Missing | Space |
 | - | - | Missing | Space |
 | - | - | Missing | Space |
 | - | - | Missing | Space |
 | - | - | Missing | Space |
 | - | - | Missing | Space |
 | - | - | Missing | Space |
 | - | - | Missing | Space |
 | - | - | Missing | Space |
 | - | - | Missing | Space |
 | - | - | Missing | Space |
 | - | - | Missing | Space |
 | - | - | Missing | Space |
 | - | - | Missing | Space |
 | - | - | Missing | Space |
 | - | - | Missing | Space |
 | - | - | Missing | Space |
 | - | - | Missing | Space |
  | - | Space | Space | Space |
! | - | Exclamation mark | Yes | Yes |
" | " | Double quote | Yes | Yes |
# | - | Hash | Yes | Yes |
$ | - | Dollar | Yes | Yes |
% | - | Percent | Yes | Yes |
& | & | Ampersand | Yes | Yes |
' | - | Apostrophe | Yes | Yes |
( | - | Left parenthesis | Yes | Yes |
) | - | Right parenthesis | Yes | Yes |
* | - | Asterisk | Yes | Yes |
+ | - | Plus | Yes | Yes |
, | - | Comma | Yes | Yes |
- | - | Hyphen | Yes | Yes |
. | - | Period | Yes | Yes |
/ | - | Slash | Yes | Yes |
0 | - | Digit 0 | Yes | Yes |
1 | - | Digit 1 | Yes | Yes |
2 | - | Digit 2 | Yes | Yes |
3 | - | Digit 3 | Yes | Yes |
4 | - | Digit 4 | Yes | Yes |
5 | - | Digit 5 | Yes | Yes |
6 | - | Digit 6 | Yes | Yes |
7 | - | Digit 7 | Yes | Yes |
8 | - | Digit 8 | Yes | Yes |
9 | - | Digit 9 | Yes | Yes |
: | - | Colon | Yes | Yes |
; | - | Semicolon | Yes | Yes |
< | < | Less than | Yes | Yes |
= | - | Equals | Yes | Yes |
> | > | Greater than | Yes | Yes |
? | - | Question mark | Yes | Yes |
@ | - | Commercial at sign | Yes | Yes |
A | - | Letter A | Yes | Yes |
B | - | Letter B | Yes | Yes |
C | - | Letter C | Yes | Yes |
D | - | Letter D | Yes | Yes |
E | - | Letter E | Yes | Yes |
F | - | Letter F | Yes | Yes |
G | - | Letter G | Yes | Yes |
H | - | Letter H | Yes | Yes |
I | - | Letter I | Yes | Yes |
J | - | Letter J | Yes | Yes |
K | - | Letter K | Yes | Yes |
L | - | Letter L | Yes | Yes |
M | - | Letter M | Yes | Yes |
N | - | Letter N | Yes | Yes |
O | - | Letter O | Yes | Yes |
P | - | Letter P | Yes | Yes |
Q | - | Letter Q | Yes | Yes |
R | - | Letter R | Yes | Yes |
S | - | Letter S | Yes | Yes |
T | - | Letter T | Yes | Yes |
U | - | Letter U | Yes | Yes |
V | - | Letter V | Yes | Yes |
W | - | Letter W | Yes | Yes |
X | - | Letter X | Yes | Yes |
Y | - | Letter Y | Yes | Yes |
Z | - | Letter Z | Yes | Yes |
[ | - | Left square bracket | Yes | Yes |
\ | - | Backslash | Yes | Yes |
] | - | Right square bracket | Yes | Yes |
^ | - | Caret | Yes | Yes |
_ | - | Underscore | Yes | Yes |
` | - | Grave accent | Yes | Yes |
a | - | Letter a | Yes | Yes |
b | - | Letter b | Yes | Yes |
c | - | Letter c | Yes | Yes |
d | - | Letter d | Yes | Yes |
e | - | Letter e | Yes | Yes |
f | - | Letter f | Yes | Yes |
g | - | Letter g | Yes | Yes |
h | - | Letter h | Yes | Yes |
i | - | Letter i | Yes | Yes |
j | - | Letter j | Yes | Yes |
k | - | Letter k | Yes | Yes |
l | - | Letter l | Yes | Yes |
m | - | Letter m | Yes | Yes |
n | - | Letter n | Yes | Yes |
o | - | Letter o | Yes | Yes |
p | - | Letter p | Yes | Yes |
q | - | Letter q | Yes | Yes |
r | - | Letter r | Yes | Yes |
s | - | Letter s | Yes | Yes |
t | - | Letter t | Yes | Yes |
u | - | Letter u | Yes | Yes |
v | - | Letter v | Yes | Yes |
w | - | Letter w | Yes | Yes |
x | - | Letter x | Yes | Yes |
y | - | Letter y | Yes | Yes |
z | - | Letter z | Yes | Yes |
{ | - | Left curly brace | Yes | Yes |
| | - | Vertical bar | Yes | Yes |
} | - | Right curly brace | Yes | Yes |
~ | - | Tilde | Yes | Yes |
 | - | Undefined | Displays ? | Missing |
€ | - | Undefined | No | Displays ? |
 | - | Undefined | No | Displays ? |
‚ | - | Comma | Yes | Yes |
ƒ | - | Florin | Yes | Yes |
„ | - | Right double quote | Yes | Yes |
… | - | Ellipsis | Yes | Yes |
† | - | Dagger | Yes | Yes |
‡ | - | Double dagger | Yes | Yes |
ˆ | - | Circumflex | Yes | Yes |
‰ | - | Permil | Yes | Yes |
Š | - | Undefined | Displays ? | Bugged |
‹ | - | Less than | Yes | Yes |
Œ | - | Capital OE ligature | Yes | Yes |
 | - | Undefined | No | Displays ? |
Ž | - | Undefined | No | Displays ? |
 | - | Undefined | No | Displays ? |
 | - | Undefined | No | Displays ? |
‘ | - | Left single quote | Yes | Yes |
’ | - | Right single quote | Yes | Yes |
“ | - | Left double quote | Yes | Yes |
” | - | Right double quote | Yes | Yes |
• | - | Bullet | Yes | Yes |
– | - | En dash | Yes | Yes |
— | - | Em dash | Yes | Yes |
˜ | - | Tilde | Yes | Yes |
™ | - | Trademark symbol | Yes | Yes |
š | - | Undefined | Displays ? | Yes |
› | - | Greater than | Yes | Yes |
œ | - | Small oe ligature | Yes | Yes |
 | - | Undefined | No | Displays ? |
ž | - | Undefined | No | Displays ? |
Ÿ | - | Capital Y umlaut | Yes | Yes |
  | | Non breaking space | Yes | Yes |
¡ | ¡ | Inverted exclamation | Yes | Yes |
¢ | ¢ | Cent sign | Yes | Yes |
£ | £ | Pound sign | Yes | Yes |
¤ | ¤ | General currency symbol | Displays ? | Displays ? |
¥ | ¥ | Yen sign | Yes | Yes |
¦ | ¦ | Broken vertical bar | Displays ? | Yes |
§ | § | Section sign | Yes | Yes |
¨ | ¨ | Umlaut | Yes | Yes |
© | © | Copyright | Yes | Yes |
ª | ª | Feminine ordinal | Yes | Yes |
« | « | Left angle quote | Yes | Yes |
¬ | ¬ | Not sign | Yes | Yes |
­ | ­ | Soft hyphen | Displays ? | Yes |
® | ® | Registered trademark | Yes | Yes |
¯ | ¯ | Macron accent | Yes | Yes |
° | ° | Degree sign | Yes | Yes |
± | ± | Plus or minus | Yes | Yes |
² | ² | Superscripted 2 | Displays ? | Yes |
³ | ³ | Superscripted 3 | Displays ? | Yes |
´ | ´ | Acute accent | Yes | Yes |
µ | µ | Micro sign | Yes | Yes |
¶ | ¶ | Paragraph | Yes | Yes |
· | · | Middle dot | Yes | Yes |
¸ | ¸ | Cedilla | Yes | Yes |
¹ | ¹ | Superscripted 1 | Displays ? | Yes |
º | º | Masculine ordinal | Yes | Yes |
» | » | Right angle quote | Yes | Yes |
¼ | ¼ | One quarter | Displays ? | Yes |
½ | ½ | One half | Displays ? | Yes |
¾ | ¾ | Three quarters | Displays ? | Yes |
¿ | ¿ | Inverted question mark | Yes | Yes |
À | À | Capital A grave | Yes | Yes |
Á | Á | Capital A acute | Yes | Yes |
 |  | Capital A circumflex | Yes | Yes |
à | à | Capital A tilde | Yes | Yes |
Ä | Ä | Capital A umlaut | Yes | Yes |
Å | Å | Capital A ring | Yes | Yes |
Æ | Æ | Capital AE ligature | Yes | Yes |
Ç | Ç | Capital C cedilla | Yes | Yes |
È | È | Capital E grave | Yes | Yes |
É | É | Capital E acute | Yes | Yes |
Ê | Ê | Capital E circumflex | Yes | Yes |
Ë | Ë | Capital E umlaut | Yes | Yes |
Ì | Ì | Capital I grave | Yes | Yes |
Í | Í | Capital I acute | Yes | Yes |
Î | Î | Capital I circumflex | Yes | Yes |
Ï | Ï | Capital I umlauut | Yes | Yes |
Ð | Ð | Capital eth | Displays ? | Bugged |
Ñ | Ñ | Capital N tilde | Yes | Yes |
Ò | Ò | Capital O grave | Yes | Yes |
Ó | Ó | Capital O acute | Yes | Yes |
Ô | Ô | Capital O circumflex | Yes | Yes |
Õ | Õ | Capital O tilde | Yes | Yes |
Ö | Ö | Capital O umlaut | Yes | Yes |
× | × | Multiply | Displays ? | Yes |
Ø | Ø | Capital O slash | Yes | Yes |
Ù | Ù | Capital U grave | Yes | Yes |
Ú | Ú | Capital U acute | Yes | Yes |
Û | Û | Capital U circumflex | Yes | Yes |
Ü | Ü | Capital U umlaut | Yes | Yes |
Ý | Ý | Capital Y acute | Displays ? | Yes |
Þ | Þ | Capital thorn | Displays ? | Bugged |
ß | ß | Small sz ligature | Yes | Yes |
à | à | Small a grave | Yes | Yes |
á | á | Small a acute | Yes | Yes |
â | â | Small a circumflex | Yes | Yes |
ã | ã | Small a tilde | Yes | Yes |
ä | ä | Small a umlaut | Yes | Yes |
å | å | Small a ring | Yes | Yes |
æ | æ | Small ae ligature | Yes | Yes |
ç | ç | Small c cedilla | Yes | Yes |
è | è | Small e grave | Yes | Yes |
é | é | Small e acute | Yes | Yes |
ê | ê | Small e circumflex | Yes | Yes |
ë | ë | Small e umlaut | Yes | Yes |
ì | ì | Small i grave | Yes | Yes |
í | í | Small i acute | Yes | Yes |
î | î | Small i circumflex | Yes | Yes |
ï | ï | Small i umlaut | Yes | Yes |
ð | ð | Small eth | Displays ? | Bugged |
ñ | ñ | Small n tilde | Yes | Yes |
ò | ò | Small o grave | Yes | Yes |
ó | ó | Small o acute | Yes | Yes |
ô | ô | Small o circumflex | Yes | Yes |
õ | õ | Small o tilde | Yes | Yes |
ö | ö | Small o umlaut | Yes | Yes |
÷ | ÷ | Divide | Yes | Yes |
ø | ø | Small o slash | Yes | Yes |
ù | ù | Small u grave | Yes | Yes |
ú | ú | Small u acute | Yes | Yes |
û | û | Small u circumflex | Yes | Yes |
ü | ü | Small u umlaut | Yes | Yes |
ý | ý | Small y acute | Displays ? | Yes |
þ | þ | Small thorn | Displays ? | Bugged |
ÿ | ÿ | Small y umlaut | Yes | Yes |
Inside <SCRIPT> tags, you are inside the JavaScript source domain and you use a different set of escape mechanisms. If you use the HTML escape mechanisms inside JavaScript source, your script is likely to break unless you are intentionally outputting them to the HTML source space via a document.write() method.
The character set you are using inside the <SCRIPT> tags is completely different to that used in HTML. The script source is written using Unicode characters (ISO 10646). If you are generating HTML, a great many of the character codes are mapped differently. This is because the HTML character entities are defined according to an ISO standard (ISO 8859). Even then, national language variants of the browser should map the character entity values to the correct character glyph which should ensure that what the designer intended is what you actually see, regardless of the actual character code transformations that take place.
Most of the character entities are supported by both MSIE and Netscape. A few characters are supported inconsistently. All of the character entities with values less than 32 are control codes anyway, so although the browsers treat them differently, it shouldn't prove to be significant. Those character entities that are undefined in the HTML specification aren't supported in the same way either, and should probably be avoided. Recent updates to the HTML standard allow for Unicode character values to be used above character entity 255, and some of these have symbolic names defined. Refer to the HTML specification available from the W3C at http://www.w3.org/TR/html4/ for further details.
Of the rest:
- The general currency symbol (¤) is unsupported.
- There is currently no Euro symbol implemented although its character entity € and Unicode value 20A0 are defined but not in the version of the Unicode standard that is currently mandated (version 2.0). Unicode is about to undergo a revision and at that time, browser manufacturers will then need to accomodate the changes to remain compliant.
- The broken vertical bar (¦) does not work on Netscape, Nor does the soft hyphen (), and neither do the superscripted numbers and fractional values.
- ETH and THORN are broken in both browsers in both upper and lower case variants.
- Netscape also lacks support for Y acute in both upper and lower case.
- Most of these are fairly obscure and not likely to cause much difficulty aside from some very specialized national language support. The Euro character, however, is likely to become more important whether the currency thrives or not.
See also: | Escaped JavaScript quotes in HTML, Portability |
Prev | Home | Next |
.html | Up | HTML Comment tag (<!-- ... -->) |
JavaScript Programmer's Reference, Cliff Wootton Wrox Press (www.wrox.com) Join the Wrox JavaScript forum at p2p.wrox.com Please report problems to support@wrox.com © 2001 Wrox Press. All Rights Reserved. Terms and conditions. |