Character Entities/Escape Sequences/Escape Characters

Certain characters in HTML are reserved, such as the less-than (<) and greater-than (>) signs, and the ampersand (&) character. If you type characters like these directly into HTML code, you will usually (although not always) get either a broken web page, or gibberish characters on the screen. In order to display reserved characters, you must use character entity references, also known as escape sequences or escape characters.

The syntax for escape characters in HTML is always the same: The ampersand (&) character, followed by the character code, and ending with a semi-colon (;). The character codes may be represented either by name (named entity) or by number (numeric entity); named entities are special text abbreviations of the character name, while numeric entities are special number codes representing the character preceded by a pound (#) sign. Remember: these codes MUST start with an ampersand and end with a semi-colon.

Examples:

Character: < (less-than sign)
Escape Character: &lt; or &#060;

Character: > (greater-than sign)
Escape Character: &gt; or &#062;

Character: © (copyright symbol)
Escape Character: &copy; or &#169;

Character: & (ampersand)
Escape Character: &amp; or &#038;

The complete list of Character Entities may be found in "HTML and XHTML: The Definitive Guide", Appendix F, pp627-632.

Note: Appendix F has a COMPLETE list of character entities/escape characters. Some of these characters are NOT specially reserved in HTML. You only have to use character entities/escape characters for reserved characters. Theoretically, you could encode all of your text as escape characters, but there is no reason to do so.

Main Menu