Simply put, an entity is a character that either is not accessible through your keyboard or one that will be incorrectly interpreted by the browser. However, these characters are resident in your computer’s system, and you can access them through the use of special codes.
The source for entity codes is the ISO-Latin1 character set. ISO stands for the International Standards Organization. The rest of the term denotes that this character set is derived from the Latin (or Roman) alphabet. Of course, there are many other character sets, derived from different alphabets. But the one you are most likely to use is ISO Latin-1; this also is the default character set for the Web.
Entities described by numbers are called numeric entities. Entities described by descriptive terms are called character entities. Many special characters are represented by both types. For example, the copyright symbol can be written either as a numeric entity, ©, or as a character entity, ©. Whichever you use, a Web browser will recognize it as the entity for the copyright symbol and display the symbol in its place.
An entity must be constructed properly for the browser to recognize it. It always begins with an ampersand (&) and closes with a semicolon (;). In between, you insert either a numeric code or a logical descriptive term. In addition, numeric entities must have the number symbol (#) preceding the entity number. Also, entities are case sensitive; always type them in exactly as you see them on a reference chart. Incidentally, some older browsers might not recognize particular character entities. It’s always a good idea to test your page in different browsers to be sure of its compatibility.
For an extensive chart of numeric and character entities, download Appendix C from the author’s Web site at www.jamespence.com.
A practical way to experiment with entities is by adding a copyright notice to your Web page. To use the entity for the copyright symbol, follow these steps:
Open template.htm and save it as entity.htm.
In the <body> section of the document, type Copyright 2015.
After the word Copyright, type the ampersand character, &.
Enter either the numeric or character code. For example, for the copyright symbol you would type copy or #169.
Close out the code by typing a semicolon. Your text should look like this:
Copyright © 2015 or Copyright © 2015
However, on a Web browser it will display this way: Copyright 2015. Try it out on a sample page. Remember to put the entities in the actual text of your Web page, not in the tags. It would be incorrect to write <h6 ©>Copyright 2015</h6>. If you do put the entity in the wrong place, the browser will just ignore it. Type in the following code for a demonstration of how entities work and for a sample of what shows up when they are entered correctly:
<html> <head> <title>Sample Entity Display</title> </head> <body> Copyright © 2015 My Trademark ® is a registered trademark. </body> </html>
When you save and display this page, you’ll notice, as in the illustration that follows, that the code for your entity is replaced by the special character that it represents: