F.8. Special Characters and More Line Breaks
When marking up text, certain characters or symbols (e.g., <) may be difficult to embed directly into an XHTML document. Some keyboards do not provide these symbols, or the presence of these symbols may 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 character entity references (in the form &code;) for representing special characters. We could correct the previous line by writing
if x < 10 then increment x by 1
which uses the character entity reference < for the less-than symbol.
Figure F.9 demonstrates how to use special characters in an XHTML document. For a list of special characters, see Appendix A, XHTML Special Characters.
Figure F.9. Special characters in XHTML.
1 6 7 8 |
"http://www.w3.org/1999/xhtml"> 9 | 10 | Internet and WWW How to Program - Contact Page 11 12 13 14 | 15 16 17 18
19 Click 20 <a href="</span"> "mailto:deitel@deitel.com">here</a> 21 to open an e-mail message addressed to 22 deitel@deitel.com. 23 24 25 26 27All information on this site is © 28 Deitel & Associates, Inc. 2004. 29 30 31 32 33 34
Note: < ¼ of the information 39 presented here is updated daily. 40 41 42 |
Lines 2728 contain other special characters, which can be expressed as either character entity references (i.e., word abbreviations such as amp for ampersand and copy for copyright) or numeric character referencesdecimal or hexadecimal (hex) values representing special characters. For example, the & character is represented in decimal and hexadecimal notation as & and &, respectively. 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 E, Number Systems.
In lines 3436, 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 or sub element, respectively. We also use character entity reference < for a less-than sign and ¼ for the fraction 1/4 (line 38).
In addition to special characters, this document introduces a horizontal rule, indicated by the
tag in line 25. Most browsers render a horizontal rule as a horizontal line. The
tag also inserts a line break above and below the horizontal line.