J.7. Special Characters and More Line Breaks

When marking up text, certain characters or symbols (e.g., <) might be difficult to embed directly into an XHTML document. Some keyboards do not provide these symbols, or the presence of these symbols could cause syntax errors. For example, the markup

 

if x < 10 then increment x by 1

results in a syntax error, because it uses the less-than character (<), which is reserved for start tags and end tags such as

and

. XHTML provides special characters or entity references (in the form &code;) for representing these characters. We could correct the previous line by writing

 

if x < 10 then increment x by 1

which uses the special character < for the less-than symbol.

Figure J.7 demonstrates how to use special characters in an XHTML document. For a list of special characters, see Appendix K. Lines 2627 contain other special characters, which are expressed either as word abbreviations (e.g., & for ampersand and © for copyright) or as hexadecimal values (e.g., & is the hexadecimal representation of &). Hexadecimal numbers are base-16 numbersdigits in a hexadecimal number have values from 0 to 15 (a total of 16 different values). The letters AF represent the hexadecimal digits corresponding to decimal values 1015. Thus, in hexadecimal notation, we can have numbers like 876 consisting solely of decimal-like digits, numbers like DA19F consisting of digits and letters, and numbers like DCB consisting solely of letters. We discuss hexadecimal numbers in detail in Appendix D.

Figure J.7. Inserting special characters into XHTML.

(This item is displayed on pages 1338 - 1339 in the print version)

"http://www.w3.org/1999/xhtml"> 9 10

1 6 7 8

Inserting special characters 11 12 13 14 15 16 17

18 Click 19 <a href="</span"> "mailto:deitel@deitel.com">here 20 </a> to open an e-mail message addressed to 21 deitel@deitel.com. 22

23 24
25 26

All information on this site is © 27 Deitel & Associates, Inc. 2005.

28 29 30 31 32 33

You may download 3.14 x 102 34 characters worth of information from this site. 35 Only one download per hour is permitted.

36 37

Note: < ¼ of the information 38 presented here is updated daily.

39 40 41

In lines 3335, we introduce three new elements. Most browsers render the del element as strike-through text. With this format, users can easily indicate document revisions. To superscript text (i.e., raise text on a line with a decreased font size) or subscript text (i.e., lower text on a line with a decreased font size), use the sup and sub elements, respectively. We also use special characters < for a less-than sign and ¼ for the fraction 1/4 (line 37).


In addition to special characters, this document introduces a horizontal rule, indicated by the


tag in line 24. Most browsers render a horizontal rule as a horizontal line. The


tag also inserts a line break above and below the horizontal line.

Категории