Professional Documents
Culture Documents
Outline 4.1 4.2 4.3 4.4 4.5 4.6 4.7 4.8 4.9 4.10 4.11 Introduction Editing XHTML First XHTML Example W3C XHTML Validation Service Headers Linking Images Special Characters and More Line Breaks Unordered Lists Nested and Ordered Lists Web Resources
Objectives
Web browser
Requests XHTML documents
Head section Title of the document Style sheets and scripts body element Body section Pages content the browser displays
Start tag
attributes (provide additional information about an
element)
name and value (separated by an equal sign)
End tag
2004 Prentice Hall, Inc. All rights reserved.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
<?xml version = "1.0"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <!-- Fig. 4.1: main.html --> <!-- Our first Web page -->
Outline
main.html (1 of 1)
<html xmlns = "http://www.w3.org/1999/xhtml"> <head> <title>Internet and WWW How to Program - Welcome</title> </head> <body> <p>Welcome to XHTML!</p> </body>
16 </html>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
<?xml version = "1.0"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <!-- Fig. 4.4: header.html --> <!-- XHTML headers -->
Outline
header.html (1 of 1)
<html xmlns = "http://www.w3.org/1999/xhtml"> <head> <title>Internet and WWW How to Program - Headers</title> </head> <body> <h1>Level 1 Header</h1> <h2>Level 2 header</h2> <h3>Level 3 header</h3> <h4>Level 4 header</h4> <h5>Level 5 header</h5> <h6>Level 6 header</h6> </body>
23 </html>
<strong> tag
Bold
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
<?xml version = "1.0"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <!-- Fig. 4.5: links.html -->
Outline
links.html (1 of 2)
<!-- Introduction to hyperlinks --> <html xmlns = "http://www.w3.org/1999/xhtml"> <head> <title>Internet and WWW How to Program - Links</title> </head> <body> <h1>Here are my favorite sites</h1> <p><strong>Click a name to go to that page.</strong></p> <!-- Create four text hyperlinks --> <p><a href = "http://www.deitel.com">Deitel</a></p> <p><a href = "http://www.prenhall.com">Prentice Hall</a></p> <p><a href = "http://www.yahoo.com">Yahoo!</a></p>
26 27 28
Outline
links.html (2 of 2)
29 </html>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
<?xml version = "1.0"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <!-- Fig. 4.6: contact.html -->
Outline
contact.html (1 of 1)
<!-- Adding email hyperlinks --> <html xmlns = "http://www.w3.org/1999/xhtml"> <head> <title>Internet and WWW How to Program - Contact Page</title> </head> <body> <p> My email address is <a href = "mailto:deitel@deitel.com"> deitel@deitel.com </a> . Click the address and your browser will open an e-mail message and address it to me. </p> </body>
24 </html>
4.7 Images
Three most popular formats
Graphics Interchange Format (GIF) Joint Photographic Experts Group (JPEG) Portable Network Graphics (PNG) img element
src attribute Specifies the location of the image file width and height
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
<?xml version = "1.0"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <!-- Fig. 4.7: picture.html -->
Outline
picture.html (1 of 1)
<!-- Adding images with XHTML --> <html xmlns = "http://www.w3.org/1999/xhtml"> <head> <title>Internet and WWW How to Program - Welcome</title> </head> <body> <p> <img src = "xmlhtp.jpg" height = "238" width = "183" alt = "XML How to Program book cover" /> <img src = "jhtp.jpg" height = "238" width = "183" alt = "Java How to Program book cover" /> </p> </body>
22 </html>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
<?xml version = "1.0"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <!-- Fig. 4.8: nav.html -->
Outline
nav.html (1 of 2)
<!-- Using images as link anchors --> <html xmlns = "http://www.w3.org/1999/xhtml"> <head> <title>Internet and WWW How to Program - Navigation Bar </title> </head> <body> <p> <a href = "links.html"> <img src = "buttons/links.jpg" width = "65" height = "50" alt = "Links Page" /> </a><br /> <a href = "list.html"> <img src = "buttons/list.jpg" width = "65" height = "50" alt = "List Example Page" /> </a><br />
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 </body> 49 </html> </p> <a href = "form.html"> <img src = "buttons/form.jpg" width = "65" height = "50" alt = "Feedback Form" /> </a><br /> <a href = "table1.html"> <img src = "buttons/table.jpg" width = "65" height = "50" alt = "Table Page" /> </a><br /> <a href = "header.html"> <img src = "buttons/header.jpg" width = "65" height = "50" alt = "Header Page" /> </a><br /> <a href = "contact.html"> <img src = "buttons/contact.jpg" width = "65" height = "50" alt = "Contact Page" /> </a><br />
Outline
nav.html (2 of 2)
4.8 Special Characters and More Line Breaks Character entity references (in the form &code;) Numeric character references (e.g. &) del
Strike-out text
sup
Superscript text
sub
Subscript text
<hr />
Horizontal rule (horizontal line)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
<?xml version = "1.0"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <!-- Fig. 4.9: contact2.html -->
Outline
contact2.html (1 of 2)
<!-- Inserting special characters --> <html xmlns = "http://www.w3.org/1999/xhtml"> <head> <title>Internet and WWW How to Program - Contact Page </title> </head> <body> <!-- special characters are entered --> <!-- using the form &code; <p> Click <a href = "mailto:deitel@deitel.com">here </a> to open an e-mail message addressed to deitel@deitel.com. </p> <hr /> <!-- inserts a horizontal rule --> -->
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 </body> 42 </html> <p>Note: <strong>< ¼</strong> of the information presented here is updated daily.</p> <!-- to strike through text use <del> tags <!-- to subscript text use <sub> tags <!-- to superscript text use <sup> tags --> --> --> <p>All information on this site is <strong>©</strong> Deitel <strong>&</strong> Associates, Inc. 2002.</p>
Outline
contact2.html (2 of 2)
<!-- 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>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
<?xml version = "1.0"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <!-- Fig. 4.10: links2.html -->
Outline
links2.html (1 of 2)
<!-- Unordered list containing hyperlinks --> <html xmlns = "http://www.w3.org/1999/xhtml"> <head> <title>Internet and WWW How to Program - Links</title> </head> <body> <h1>Here are my favorite sites</h1> <p><strong>Click on a name to go to that page.</strong></p> <!-- create an unordered list --> <ul> <!-- add four list items --> <li><a href = "http://www.deitel.com">Deitel</a></li> <li><a href = "http://www.w3.org">W3C</a></li>
Outline
links2.html (2 of 2)
4.10 Nested and Ordered Lists Represent hierarchical relationships Ordered lists (ol)
Creates a list in which each item begins with a number
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
<?xml version = "1.0"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <!-- Fig. 4.11: list.html -->
Outline
list.html (1 of 3)
<!-- Advanced Lists: nested and ordered --> <html xmlns = "http://www.w3.org/1999/xhtml"> <head> <title>Internet and WWW How to Program - Lists</title> </head> <body> <h1>The Best Features of the Internet</h1> <!-- create an unordered list --> <ul> <li>You can meet new people from countries around the world.</li> <li> You have access to new media as it becomes public:
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
<!-- this starts a nested list, which uses a --> <!-- modified bullet. The list ends when you --> <!-- close the <ul> tag. <ul> <li>New games</li> <li> New applications <!-- nested ordered list --> <ol> <li>For business</li> <li>For pleasure</li> </ol> </li> <li>Around the clock news</li> <li>Search engines</li> <li>Shopping</li> <li> Programming <!-- another nested ordered list --> <ol> <li>XML</li> <li>Java</li> -->
Outline
list.html (2 of 3)
Outline
list.html (3 of 3)
</ul> <!-- ends the nested list of line 27 --> </li> <li>Links</li> <li>Keeping in touch with old friends</li> <li>It is the technology of the future!</li> <!-- ends the unordered list of line 18 -->