Most fonts now include special characters for European languages, such as the accented é in Café. There are also a few mathematical symbols and special punctuation marks such as the circular • bullet. You can insert these special characters at any point in an HTML document by looking up the appropriate codes in Table 5.2. You'll find an even more extensive list of codes for multiple character sets online at http://www.webstandards.org/learn/reference/named_entities.html.
For example, the word café would look like this: café HTML/XHTML uses a special code known as a character entity to represent special characters such as © and ®. Character entities are always specified starting with a & and ending with a ;. Table 5.2 lists the most commonly used character entities, although HTML supports many more.
Although you can specify character entities by number, each symbol also has a mnemonic name that is often easier to remember. Here is another way to write café: café Notice that there are also codes for the angle brackets, quotation, and ampersand in Table 5.2. You need to use the codes if you want these symbols to appear on your pages; otherwise, the web browser interprets them as HTML commands. In Listing 5.7 and Figure 5.8, several of the symbols from Table 5.2 are shown in use. Listing 5.7. Special Character Codes<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <title>Punctuation Lines</title> </head> <body> <p> Q: What should you do when a British banker picks a fight with you?<br /> A: £ some ¢¢ into him. <hr /> Q: What do you call it when a judge takes part of a law off the books?<br /> A: § violence. <hr /> Q: What did the football coach get from the locker room vending machine in the middle of the game?<br /> A: A ¼ back at ½ time. <hr /> Q: How hot did it get when the police detective interrogated the mathematician?<br /> A: x³° <hr /> Q: What does a punctilious plagiarist do?<br /> A: © <hr /> </p> </body> </html> Figure 5.8. This is how the HTML page in Listing 5.7 will look in most web browsers. |