HTML Tutorials - Herong's Tutorial Examples - Version 2.01, by Dr. Herong Yang
Using Character Entity References
This section describes how character entity references can be used in HTML documents. HTML5 supports about 2231 predefined character entity reference names. Most of them are case sensitive and end with ';'.
HTML5 supports a predefined set of character entity reference names that are mapped to a set of Unicode code points. You need to remember the following notes when using them:
1. There are about 2231 character entity reference names defined in HTML5. Check the HTML5 specification document at http://www.w3.org/TR/html5/syntax.html to get the complete list of character entity reference names.
2. Most reference names end with ";". But for some commonly used characters, two versions are support: one with ";" and one without ";". For example, both "lt;" and "lt" are supported referring to the same code point of U+0003C. It is strongly recommended to use the reference name with ";".
3. Most reference names are case sensitive. But for some commonly used characters, two versions are support: one with upper case and one with lower case. For example, both "LT;" and "lt" are supported referring to the same code point of U+0003C. It is strongly recommended to use the lower case reference name.
4. You enter character entity references to refer to their mapped Unicode code points in a HTML document using this syntax: "&reference_name;". "<" is entity reference to code point of U+0003C.
5. Character entity references can be used in element contents of all HTML elements except "script" and "style" elements.
6. Character entity references in "svg" and "math" element contents must follow XML rules.
7. Character entity references can also be used in attribute values.
Here is example HTML document that shows you how to use character entity references:
<!DOCTYPE html> <!-- HTM_Character_Entity_References_Example.html - Copyright (c) 2014, HerongYang.com, All Rights Reserved. --> <html> <head> <!-- Character Entity References in "title" element --> <title>"Character Entity References" Example</title> </head> <body> <!-- Character Entity References in element content --> <pre> U+0003C < U+0003C < U+0003C < U+0005B [ U+0226A ≪ </pre> <!-- Character Entity References in attribute value --> <img src="image.gif" alt="In attribute value: <"> <!-- Bad examples --> <script>U+0003C <</script> <pre> &lsqb "lsqb;" is defined, not "lsqb" &LSGB; "lsqb;" is defined, not "LSGB" &lT; "Lt;" is defined, not "lT;" </pre> </body> </html>
When the above HTML document is viewed in a Web browser, you will see something like this:
Last update: 2014.
Table of Contents