Home | | Internet & World Wide Web HOW TO PROGRAM | | Internet Programming | | Web Programming | Special Characters and Horizontal Rules - XHTML

Chapter: Internet & World Wide Web HOW TO PROGRAM - The Ajax Client - Introduction to XHTML

| Study Material, Lecturing Notes, Assignment, Reference, Wiki description explanation, brief detail |

Special Characters and Horizontal Rules - XHTML

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.

Special Characters and Horizontal Rules

 

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

 

<p>if x < 10 then increment x by 1</p>

 

results in a syntax error because it uses the less-than character (<), which is reserved for start tags and end tags such as <p> and </p>. XHTML provides character entity references (in the form &code;) for representing special characters. We could correct the previous line by writing

 

<p>if x &lt; 10 then increment x by 1</p>

 

which uses the character entity reference &lt; for the less-than symbol (<).

 

Figure 4.7 demonstrates how to use special characters in an XHTML document. For a list of special characters, see Appendix A, XHTML Special Characters.

Lines 24–25 contain other special characters, which can be expressed as either char-acter entity references (coded using word abbreviations such as &amp; for ampersand and &copy; for copyright) or numeric character references—decimal or hexadecimal (hex) values representing special characters. For example, the & character is represented in dec-imal and hexadecimal notation as &#38; and &#x26;, respectively. Hexadecimal numbers are base 16 numbers—digits in a hexadecimal number have values from 0 to 15 (a total of 16 different values). The letters A–F represent the hexadecimal digits corresponding to decimal values 10–15. Thus in hexadecimal notation we can have numbers like 876 con-sisting 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.

        <?xml version = "1.0" encoding = "utf-8"?>

 

        <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"

 

              "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

 

        <!-- Fig. 4.7: contact2.html -->

 

        <!-- Inserting special characters. -->

 

        <html xmlns = "http://www.w3.org/1999/xhtml">

 

              <head>

 

                     <title>Contact Page</title>

 

                </head>

                <body>

                       <p>

 

                             Click

 

                             <a href = "mailto:deitel@deitel.com">here</a>

 

                             to open an email message addressed to

 

                             deitel@deitel.com.

                       </p>

             <hr /> <!-- inserts a horizontal rule -->

 

                       <!-- special characters are entered -->

 

                       <!-- using the form &code; -->

 

                       <p>All information on this site is <strong>&copy;

 

                             Deitel &amp; Associates, Inc. 2007.</strong></p>

 

                       <!-- to strike through text use <del> tags -->

 

                       <!-- to subscript text use <sub> tags -->

 

                       <!-- to superscript text use <sup> tags -->

 

                       <!-- these tags are nested inside other tags -->

 

                       <p><del>You may download 3.14 x 10<sup>2</sup>

 

                             characters worth of information from this site.</del>

 

                             Only <sub>one</sub> download per hour is permitted.</p>

 

                       <p><em>Note: &lt; &frac14; of the information

 

                             presented here is updated daily.</em></p>

 

                </body>

 

</html>


In lines 31–33, we introduce four new elements. Most browsers render the del ele-ment as strike-through text. With this format users can easily indicate document revisions. To superscript text (i.e., raise text above the baseline and decreased font size) or subscript text (i.e., lower text below the baseline and decreased font size), use the sup or sub element, respectively. The paragraph in lines 34–35 contains an em element, which indicates that its contents should be emphasized. Browsers usually render em elements in an italic font. We also use character entity reference &lt; for a less-than sign and &frac14; for the frac-tion 1/4 (line 34).

 

In addition to special characters, this document introduces a horizontal rule, indi-cated by the <hr /> tag in line 22. Most browsers render a horizontal rule as a horizontal line with a blank line above and below it.

 

Study Material, Lecturing Notes, Assignment, Reference, Wiki description explanation, brief detail


Copyright © 2018-2020 BrainKart.com; All Rights Reserved. Developed by Therithal info, Chennai.