Download presentation
Presentation is loading. Please wait.
Published byDoddy Kusnadi Modified over 6 years ago
1
张奇 复旦大学 计算机科学技术学院 qz@fudan.edu.cn 2015年4月
多媒体技术基础 第6讲 HTML5 & CSS 多媒体技术基础 第5讲 HTML 张奇 复旦大学 计算机科学技术学院 2015年4月
2
Chapter 4 - Introduction to XHTML: Part 1
Outline 4.1 Introduction 4.2 Elements and Attributes 4.3 Editing XHTML 4.4 Common Elements 4.5 W3C XHTML Validation Service 4.6 Headers 4.7 Linking 4.8 Images 4.9 Special Characters and More Line Breaks Unordered Lists Nested and Ordered Lists Internet and World Wide Web Resources
3
Presentation of a document vs. structure
4.1 Introduction HTML HyperText Markup Language Not a procedural programming language like C, Fortran, Cobol or Pascal Markup language Identify elements of a page so that a browser can render that page on your computer screen Presentation of a document vs. structure
4
Forgetting to close tags is a syntax error
4.2 Markup Languages Markup language Used to format text and information HTML Marked up with elements, delineated by tags Tags: keywords contained in pairs of angle brackets HTML tags Not case sensitive Good practice to keep all the letters in one case Forgetting to close tags is a syntax error
5
HTML files or documents
4.3 Editing HTML HTML files or documents Written in source-code form using text editor Notepad: Start-Programs-Accessories HTML-Kit: HTML files .htm or .html extensions Name your files to describe their functionality File name of your home page should be index.html Errors in HTML Usually not fatal
6
4.4 Common Elements Always include the <HTML>…</HTML> tags
Comments placed inside <!--…--!> tags HTML documents HEAD section Info about the document Info in header not generally rendered in display window TITLE element names your Web page BODY section Page content Includes text, images, links, forms, etc. Elements include backgrounds, link colors and font faces P element forms a paragraph, blank line before and after
7
Main.html Program Output
1 <?xml version = "1.0"?> 2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" " 4 5 <!-- Fig. 4.1: main.html --> 6 <!-- Our first Web page --> 7 8 <html xmlns = " <head> <title>Internet and WWW How to Program - Welcome</title> </head> 12 <body> <p>Welcome to XHTML!</p> </body> 16 </html> Main.html Program Output The text between the title tags appears as the title of the web page. Elements between the body tags of the html document appear in the body of the web page
8
4.5 W3C XHTML Validation Service
Fig. 4.2 Validating an XHTML document. (Courtesy of World Wide Web Consortium (W3C).)
9
4.5 W3C XHTML Validation Service
Fig. 4.3 XHTML validation results. (Courtesy of World Wide Web Consortium (W3C).)
10
1 <?xml version = "1.0"?> 2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" " 4 5 <!-- Fig. 4.4: header.html --> 6 <!-- XHTML headers > 7 8 <html xmlns = " <head> <title>Internet and WWW How to Program - Headers</title> </head> 12 <body> 14 <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> 21 </body> 23 </html> Header.html Every XHTML document is required to have opening and closing html tags. The font size of the text between tags decreases as the header level increases.
11
Program Output Select a header based on the amount of emphasis you would like to give that text.
12
Text between strong tags will appear bold.
1 <?xml version = "1.0"?> 2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" " 4 5 <!-- Fig. 4.5: links.html > 6 <!-- Introduction to hyperlinks --> 7 8 <html xmlns = " <head> <title>Internet and WWW How to Program - Links</title> </head> 12 <body> 14 <h1>Here are my favorite sites</h1> 16 <p><strong>Click on a name to go to that page.</strong></p> 18 <p><a href = " 20 <p><a href = " Hall</a></p> 22 <p><a href = " 24 <p><a href = " Today</a></p> 26 </body> 28 </html> Links.html Text between strong tags will appear bold. Linking is accomplished in XHTML with the anchor (a) element. The text between the a tags is the anchor for the link. Elements placed between paragraph tags will be set apart from other elements on the page with a vertical line before and after it. The anchor links to the page that’s value is given by the href attribute.
13
Program Output Clicking on the “Deitel” link will open up the Deitel homepage in a new browser window.
14
1 <?xml version = "1.0"?> 2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" " 4 5 <!-- Fig. 4.6: contact.html --> 6 <!-- Adding hyperlinks --> 7 8 <html xmlns = " <head> <title>Internet and WWW How to Program - Contact Page </title> </head> 13 <body> 15 <p>My address is <a href = </a>. Click the address and your browser will open an message and address it to me.</p> 20 </body> 22 </html> Contact.html To create an link include “mailto:” before the address in the href attribute.
15
Program Output When a user clicks on an link, an message addressed to the value of the link will open up.
16
1 <?xml version = "1.0"?> 2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" " 4 5 <!-- Fig. 4.7: picture.html --> 6 <!-- Adding images with XHTML --> 7 8 <html xmlns = " <head> <title>Internet and WWW How to Program - Welcome</title> </head> 12 <body> 14 <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> 20 </html> Picture.html The value of the src attribute of the image element is the location of the image file. The height and width attributes of the image element give the height and width of the image. The value of the alt attribute gives a description of the image. This description is displayed if the image cannot be displayed.
17
Program Output The second image could not be displayed properly, so the value of its alt attribute is displayed instead.
18
A line break will render an empty line on a web page.
1 <?xml version = "1.0"?> 2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" " 4 5 <!-- Fig. 4.8: nav.html > 6 <!-- Using images as link anchors --> 7 8 <html xmlns = " <head> <title>Internet and WWW How to Program - Navigation Bar </title> </head> 13 <body> 15 <p> <a href = "links.html"> <img src = "buttons/links.jpg" width = "65" height = "50" alt = "Links Page" /></a><br /> 20 <a href = "list.html"> <img src = "buttons/list.jpg" width = "65" height = "50" alt = "List Example Page" /></a><br /> 24 <a href = "contact.html"> <img src = "buttons/contact.jpg" width = "65" height = "50" alt = "Contact Page" /></a><br /> 28 <a href = "header.html"> <img src = "buttons/header.jpg" width = "65" height = "50" alt = "Header Page" /></a><br /> 32 <a href = "table.html"> <img src = "buttons/table.jpg" width = "65" height = "50" alt = "Table Page" /></a><br /> Nav.html Placing an image element between anchor tags, creates an image that is an anchor for a link. A line break will render an empty line on a web page.
19
Nav.html Program Output
36 <a href = "form.html"> <img src = "buttons/form.jpg" width = "65" height = "50" alt = "Feedback Form" /></a><br /> </p> 41 </body> 43 </html> Nav.html Program Output Clicking on the image entitled “links” brings the user to the page on the right. Using an image as an anchor works exactly the same as using text.
20
The horizontal rule element renders a horizontal line on the web page.
1 <?xml version = "1.0"?> 2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" " 4 5 <!-- Fig. 4.9: contact2.html > 6 <!-- Inserting special characters --> 7 8 <html xmlns = " <head> <title>Internet and WWW How to Program - Contact Page </title> </head> 13 <body> 15 <!-- Special characters are entered --> <!-- using the form &code; > <p>My address is <a href = </a>. Click on the address and your browser will automatically open an message and address it to my address.</p> 23 <hr /> <!-- Inserts a horizontal rule --> 25 <p>All information on this site is <strong>©</strong> Deitel <strong>&</strong> Associates, Inc </p> 28 <!-- Text can be struck out with a set of > <!-- <del>...</del> tags, it can be set in subscript --> <!-- with <sub>...</sub>, and it can be set into > <!-- superscript with <sup...</sup> > <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> Contact2.html The horizontal rule element renders a horizontal line on the web page. Special characters are denoted with an ampersand (&) and an abbreviation for that character. In this case, the special characters are ampersand and copyright.
21
Contact2.html Program Output
36 <p>Note: <strong>< ¼</strong> of the information presented here is updated daily.</p> 39 </body> 41 </html> Contact2.html Program Output Text placed between del tags is struck out.. Text placed between the sub tags is subscripted. Text placed between the sup tags is superscripted.
22
1 <?xml version = "1.0"?> 2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" " 4 5 <!-- Fig. 4.10: links2.html > 6 <!-- Unordered list containing hyperlinks --> 7 8 <html xmlns = " <head> <title>Internet and WWW How to Program - Links</title> </head> 12 <body> 14 <h1>Here are my favorite sites</h1> 16 <p><strong>Click on a name to go to that page.</strong></p> 18 <ul> <li><a href = " 21 <li><a href = " Hall </a></li> 24 <li><a href = " 26 <li><a href = " Today</a> </li> </ul> </body> 31 </html> Links2.html The entries in an unordered list must be included between the <ul> and </ul> tags. An entry in the list must be placed between the <li> and </li> tags.
23
Program Output Each entry in the list is rendered on its own line with a bullet before it.
24
By inserting a list as an entry in another list, lists can be nested.
1 <?xml version = "1.0"?> 2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " 4 5 <!-- Fig. 4.11: list.html > 6 <!-- Advanced Lists: nested and ordered --> 7 8 <html xmlns = " <head> <title>Internet and WWW How to Program - Lists</title> </head> 12 <body> 14 <h1>The Best Features of the Internet</h1> 16 <ul> <li>You can meet new people from countries around the world.</li> <li>You have access to new media as it becomes public: 21 <!-- 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 28 <!-- Another nested list --> <ol type = "I"> <li>For business</li> <li>For pleasure</li> </ol> <!-- Ends the double nested list --> </li> 35 List.html By inserting a list as an entry in another list, lists can be nested. Entries for an ordered list must be placed between the <ol> and </ol> tags.
25
Text placed between the em tags will be italicized.
<li>Around the clock news</li> <li>Search engines</li> <li>Shopping</li> <li>Programming 40 <ol type = "a"> <li>XML</li> <li>Java</li> <li>XHTML</li> <li>Scripts</li> <li>New languages</li> </ol> 48 </li> 50 </ul> <!-- Ends the first level nested list --> </li> 53 <li>Links</li> <li>Keeping in touch with old friends</li> <li>It is the technology of the future!</li> 57 </ul> <!-- Ends the primary unordered list --> 59 <h1>My 3 Favorite <em>CEOs</em></h1> 61 <!-- ol elements without a type attribute > <!-- have a numeric sequence type (i.e., 1, 2, ...) --> <ol> <li>Harvey Deitel</li> <li>Bill Gates</li> <li>Michael Dell</li> </ol> List.html The type attribute of the ordered list element allows you to select a sequence type to order the list. Text placed between the em tags will be italicized.
26
List.html Program Output
69 </body> 71 </html> List.html Program Output Nested lists are indented underneath the main list. Some sequence types available to order lists are roman numerals, letters and numbers.
27
Chapter 5 - Introduction to XHTML: Part 2
Outline 5.1 Introduction 5.2 Basic XHTML Tables 5.3 Intermediate XHTML Tables and Formatting 5.4 Basic XHTML Forms 5.5 More Complex XHTML Forms 5.6 Internal Linking 5.7 Creating and Using Image Maps 5.8 <meta> Tags 5.9 frameset Element Nested framesets Internet and World Wide Web Resources
28
The border attribute gives the size in pixels of the table’s border.
1 <?xml version = "1.0"?> 2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" " 4 5 <!-- Fig. 5.1: table1.html --> 6 <!-- Creating a basic table --> 7 8 <html xmlns = " <head> <title>A simple XHTML table</title> </head> 12 <body> 14 <!-- The <table> tag opens a table --> <table border = "1" width = "40%" summary = "This table provides information about the price of fruit"> 19 <!-- The <caption> tag summarizes the table's --> <!-- contents (this helps the visually impaired) --> <caption><strong>Price of Fruit</strong></caption> 23 <!-- The <thead> is the first section of a --> <!-- table. It formats the table header --> <!-- area. <th> inserts a heading cell > <thead> <tr> <th>Fruit</th> <th>Price</th> </tr> </thead> Table1.html The border attribute gives the size in pixels of the table’s border. The width attribute gives the width of the table. The summary attribute describes the table’s contents. Text placed in a table header is rendered bold and centered in the cell.
29
The body of the table is placed between the tbody tags.
33 <!-- All table content goes is enclosed within --> <!-- <tbody>. <tr> inserts a table row. <td> --> <!-- inserts a data cell > <tbody> <tr> <td>Apple</td> <td>$0.25</td> </tr> 42 <tr> <td>Orange</td> <td>$0.50</td> </tr> 47 <tr> <td>Banana</td> <td>$1.00</td> </tr> 52 <tr> <td>Pineapple</td> <td>$2.00</td> </tr> </tbody> 58 <tfoot> <tr> <th>Total</th> <th>$3.75</th> </tr> </tfoot> 65 </table> Table1.html The body of the table is placed between the tbody tags. Table rows are created using the tr element Data placed between td tags are placed in an individual cell. The table footer belongs at the bottom of the table. It formats text in a similar manner to a table header.
30
Table1.html Program Output
67 </body> 69 </html> Table1.html Program Output Table Caption Table header Start of table body End of table body Table footer
31
The align attribute is used to horizontally align data in a cell.
1 <?xml version = "1.0"?> 2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" " 4 5 <!-- Fig. 5.2: table2.html > 6 <!-- Intermediate table design --> 7 8 <html xmlns = " <head> <title>Internet and WWW How to Program - Tables</title> </head> 12 <body> 14 <h1>Table Example Page</h1> 16 <table border = "1"> <caption>Here is a more complex sample table.</caption> 19 <!-- <colgroup> and <col> are used to --> <!-- format entire columns at once. --> <!-- span determines how many columns --> <!-- the col tag affects > <colgroup> <col align = "right" span = "1" /> </colgroup> 27 <thead> 29 Table2.html The span attribute indicates width of the data cell in number of columns. The align attribute is used to horizontally align data in a cell.
32
30 <!-- rowspans and colspans merge the specified -->
<!-- number of cells vertically or horizontally --> <tr> 33 <!-- Merge two rows --> <th rowspan = "2"> <img src = "camel.gif" width = "205" height = "167" alt = "Picture of a camel" /> </th> 39 <!-- Merge four columns --> <th colspan = "4" valign = "top"> <h1>Camelid comparison</h1><br /> <p>Approximate as of 8/99</p> </th> </tr> 46 <tr valign = "bottom"> <th># of Humps</th> <th>Indigenous region</th> <th>Spits?</th> <th>Produces Wool?</th> </tr> 53 </thead> 55 <tbody> 57 <tr> <th>Camels (bactrian)</th> <td>2</td> <td>Africa/Asia</td> <td rowspan = "2">Llama</td> <td rowspan = "2">Llama</td> </tr> Table2.html The value of the colspan attribute gives the amount of columns taken up by the cell. The vertical alignment of data in a cell can be specified with the valign attribute. The value of the rowspan attribute gives the amount of rows taken up by the cell.
33
Table2.html Program Output
65 <tr> <th>Llamas</th> <td>1</td> <td>Andes Mountains</td> </tr> 71 </tbody> 73 </table> 75 </body> 77 </html> Table2.html Program Output Cell spanning the size of two rows. Cell spanning the size of four columns.
34
Each form must begin and end with form tags.
1 <?xml version = "1.0"?> 2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" " 4 5 <!-- Fig. 5.3: form.html --> 6 <!-- Form Design Example 1 --> 7 8 <html xmlns = " <head> <title>Internet and WWW How to Program - Forms</title> </head> 12 <body> 14 <h1>Feedback Form</h1> 16 <p>Please fill out this form to help us improve our site.</p> 19 <!-- This tag starts the form, gives the method of --> <!-- sending information and the location of form --> <!-- scripts. Hidden inputs contain > <!-- non-visual information > <form method = "post" action = "/cgi-bin/formmail"> 25 <p> <input type = "hidden" name = "recipient" value = /> <input type = "hidden" name = "subject" value = "Feedback Form" /> <input type = "hidden" name = "redirect" value = "main.html" /> </p> Form.html Each form must begin and end with form tags. The method attribute specifies how the form’s data is sent to the Web server. The post method appends form data to the browser request. The value of the action attribute specifies the URL of a script on the Web server. Input elements are used to send data to the script that processes the form. A hidden value for the type attribute sends data that is not entered by the user.
35
The value attribute displays a name on the buttons created.
34 <!-- <input type = "text"> inserts a text box --> <p><label>Name: <input name = "name" type = "text" size = "25" maxlength = "30" /> </label></p> 40 <p> <!-- input types "submit" and "reset" insert --> <!-- buttons for submitting and clearing the --> <!-- form's contents > <input type = "submit" value = "Submit Your Entries" /> <input type = "reset" value = "Clear Your Entries" /> </p> 50 </form> 52 </body> 54 </html> The label element describes the data the user needs to enter in the text box. Form.html The size attribute gives the number of characters visible in the text box. The maxlength attribute gives the maximum number of characters the user can input. The value attribute displays a name on the buttons created.
36
Text box created using input element.
Program Output Text box created using input element. Submit button created using input element. Reset button created using input element.
37
Form2.html 1 <?xml version = "1.0"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" " 4 5 <!-- Fig. 5.4: form2.html --> 6 <!-- Form Design Example 2 --> 7 8 <html xmlns = " <head> <title>Internet and WWW How to Program - Forms</title> </head> 12 <body> 14 <h1>Feedback Form</h1> 16 <p>Please fill out this form to help us improve our site.</p> 19 <form method = "post" action = "/cgi-bin/formmail"> 21 <p> <input type = "hidden" name = "recipient" value = /> <input type = "hidden" name = "subject" value = "Feedback Form" /> <input type = "hidden" name = "redirect" value = "main.html" /> </p> 30 <p><label>Name: <input name = "name" type = "text" size = "25" /> </label></p> 34 Form2.html
38
35 <!-- <textarea> creates a multiline textbox -->
<p><label>Comments:<br /> <textarea name = "comments" rows = "4" cols = "36"> 38 Enter your comments here. </textarea> </label></p> 41 <!-- <input type = "password"> inserts a --> <!-- textbox whose display is masked with --> <!-- asterisk characters > <p><label> Address: <input name = " " type = "password" size = "25" /> </label></p> 49 <p> <strong>Things you liked:</strong><br /> 52 <label>Site design <input name = "thingsliked" type = "checkbox" value = "Design" /></label> 56 <label>Links <input name = "thingsliked" type = "checkbox" value = "Links" /></label> 60 <label>Ease of use <input name = "thingsliked" type = "checkbox" value = "Ease" /></label> 64 <label>Images <input name = "thingsliked" type = "checkbox" value = "Images" /></label> 68 The textarea element renders a text area when the page is displayed. The size of the text area can be specified with the rows and cols attribute. Form2.html Setting an input element’s type attribute to checkbox will create a checkbox. Checkboxes that belong to the same group must have same value in the name attribute.
39
Form2.html Program Output
<label>Source code <input name = "thingsliked" type = "checkbox" value = "Code" /></label> </p> 73 <p> <input type = "submit" value = "Submit Your Entries" /> <input type = "reset" value = "Clear Your Entries" /> </p> 78 </form> 80 </body> 82 </html> Form2.html Program Output Text area created with input element. Checkbox options created with input element.
40
Form3.html 1 <?xml version = "1.0"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" " 4 5 <!-- Fig. 5.5: form3.html --> 6 <!-- Form Design Example 3 --> 7 8 <html xmlns = " <head> <title>Internet and WWW How to Program - Forms</title> </head> 12 <body> 14 <h1>Feedback Form</h1> 16 <p>Please fill out this form to help us improve our site.</p> 19 <form method = "post" action = "/cgi-bin/formmail"> 21 <p> <input type = "hidden" name = "recipient" value = /> <input type = "hidden" name = "subject" value = "Feedback Form" /> <input type = "hidden" name = "redirect" value = "main.html" /> </p> 30 <p><label>Name: <input name = "name" type = "text" size = "25" /> </label></p> 34 Form3.html
41
Form3.html 35 <p><label>Comments:<br />
<textarea name = "comments" rows = "4" cols = "36"></textarea> </label></p> 39 <p><label> Address: <input name = " " type = "password" size = "25" /></label></p> 43 <p> <strong>Things you liked:</strong><br /> 46 <label>Site design <input name = "things" type = "checkbox" value = "Design" /></label> 50 <label>Links <input name = "things" type = "checkbox" value = "Links" /></label> 54 <label>Ease of use <input name = "things" type = "checkbox" value = "Ease" /></label> 58 <label>Images <input name = "things" type = "checkbox" value = "Images" /></label> 62 <label>Source code <input name = "things" type = "checkbox" value = "Code" /></label> </p> 67 Form3.html
42
The checked attribute will mark this radio option by default.
<!-- <input type = "radio" /> creates a radio > <!-- button. The difference between radio buttons --> <!-- and checkboxes is that only one radio button --> <!-- in a group can be selected > <p> <strong>How did you get to our site?:</strong><br /> 74 <label>Search engine <input name = "how get to site" type = "radio" value = "search engine" checked = "checked" /> </label> 79 <label>Links from another site <input name = "how get to site" type = "radio" value = "link" /></label> 83 <label>Deitel.com Web site <input name = "how get to site" type = "radio" value = "deitel.com" /></label> 87 <label>Reference in a book <input name = "how get to site" type = "radio" value = "book" /></label> 91 <label>Other <input name = "how get to site" type = "radio" value = "other" /></label> 95 </p> 97 Form3.html The checked attribute will mark this radio option by default. An input element with type value equal to radio creates radio buttons.
43
The select element creates a drop down list.
<label>Rate our site: 100 <!-- The <select> tag presents a drop-down --> <!-- list with choices indicated by the --> <!-- <option> tags > <select name = "rating"> <option selected = "selected">Amazing</option> <option>10</option> <option>9</option> <option>8</option> <option>7</option> <option>6</option> <option>5</option> <option>4</option> <option>3</option> <option>2</option> <option>1</option> <option>Awful</option> </select> 118 </label> </p> 121 <p> <input type = "submit" value = "Submit Your Entries" /> <input type = "reset" value = "Clear Your Entries" /> </p> 127 </form> 129 </body> 131 </html> Form3.html The select element creates a drop down list. The selected attribute selects a default value for the drop down list. The option tag is used for each option in the drop down list.
44
Radio box list created with input element.
Program Output Radio box list created with input element. Drop down box list created with input element.The Amazing option is selected as a default value.
45
Program Output
46
1 <?xml version = "1.0"?> 2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" " 4 5 <!-- Fig. 5.6: links.html --> 6 <!-- Internal Linking > 7 8 <html xmlns = " <head> <title>Internet and WWW How to Program - List</title> </head> 12 <body> 14 <!-- <a name = ".."></a> creates an internal hyperlink --> <p><a name = "features"></a></p> <h1>The Best Features of the Internet</h1> 18 <!-- An internal link's address is "#linkname" > <p><a href = "#ceos">Go to <em>Favorite CEOs</em></a></p> 21 <ul> <li>You can meet people from countries around the world.</li> 25 <li>You have access to new media as it becomes public: <ul> <li>New games</li> <li>New applications <ul> <li>For Business</li> <li>For Pleasure</li> </ul> </li> 35 Links.html To internally link, place a # sign in front of the name of the desired anchor element within the page.
47
36 <li>Around the clock news</li>
<li>Search Engines</li> <li>Shopping</li> <li>Programming <ul> <li>XHTML</li> <li>Java</li> <li>Dynamic HTML</li> <li>Scripts</li> <li>New languages</li> </ul> </li> </ul> </li> 50 <li>Links</li> <li>Keeping in touch with old friends</li> <li>It is the technology of the future!</li> </ul> 55 <!-- Named anchor --> <p><a name = "ceos"></a></p> <h1>My 3 Favorite <em>CEOs</em></h1> 59 <p> 61 <!-- Internal hyperlink to features --> <a href = "#features">Go to <em>Favorite Features</em> </a></p> 65 Links.html An anchor named ceos will be created at this point on the page. This anchor does not link and will not be seen on the page. However, other anchors can refer to this anchor and link to it.
48
Links.html Program Output
<ol> <li>Bill Gates</li> <li>Steve Jobs</li> <li>Michael Dell</li> </ol> 71 </body> 73 </html> Links.html Program Output Clicking on this internal link will bring the user to the bottom of the page where My 3 Favorite CEOs is located.
49
The area element is used to create hotspots.
1 <?xml version = "1.0" ?> 2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" " 4 5 <!-- Fig. 5.7: picture.html > 6 <!-- Creating and Using Image Maps --> 7 8 <html xmlns = " <head> <title> Internet and WWW How to Program - Image Map </title> </head> 14 <body> 16 <p> 18 <!-- The <map> tag defines an image map --> <map id = "picture"> 21 <!-- The "shape = rect" indicates a rectangular --> <!-- area, with coordinates for the upper-left --> <!-- and lower-right corners > <area href = "form.html" shape = "rect" coords = "2,123,54,143" alt = "Go to the feedback form" /> <area href = "contact.html" shape = "rect" coords = "126,122,198,143" alt = "Go to the contact page" /> <area href = "main.html" shape = "rect" coords = "3,7,61,25" alt = "Go to the homepage" /> <area href = "links.html" shape = "rect" coords = "168,5,197,25" alt = "Go to the links page" /> Picture.html The area element is used to create hotspots. The shape attribute defines a shape for the hotspot. The first two integers of the coordinate attribute define the (x,y) coordinate of the upper-left hand corner of the rectangle. The last two integers define the (x,y) coordinate of the lower-right hand corner of the rectangle.
50
36 <!-- Value poly creates a hotspot in the shape --> <!-- of a polygon, defined by coords > <area shape = "poly" alt = " the Deitels" coords = "162,25,154,39,158,54,169,51,183,39,161,26" href = /> 42 <!-- The "shape = circle" indicates a circular --> <!-- area with center and radius listed > <area href = shape = "circle" coords = "100,36,33" alt = " the Deitels" /> </map> 49 <!-- <img src =... usemap = "#id"> indicates that the --> <!-- indicated image map is used with this image > <img src = "deitel.gif" width = "200" height = "144" alt = "Deitel logo" usemap = "#picture" /> </p> </body> 56 </html> Picture.html Assigning poly to the shape attribute creates a polygon with coordinates defined by the coords attribute. Assigning circle to the shape attribute creates a circle, with a center and radius specified by the coords attribute. The image map assigned to the usemap attribute will be used with the image. The # in front of the name of the image map indicates that an internal image map is being used.
51
Selecting the Feedback hotspot links to the page below.
Program Output Selecting the Feedback hotspot links to the page below. Hotspots created using the area element.
52
The name attribute describes the type of meta element.
1 <?xml version = "1.0"?> 2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" " 4 5 <!-- Fig. 5.8: main.html --> 6 <!-- <meta> tag > 7 8 <html xmlns = " <head> <title>Internet and WWW How to Program - Welcome</title> 11 <!-- <meta> tags give search engines information --> <!-- they need to catalog your site > <meta name = "keywords" content = "Webpage, design, XHTML, tutorial, personal, help, index, form, contact, feedback, list, links, frame, deitel" /> 17 <meta name = "description" content = "This Web site will help you learn the basics of XHTML and Webpage design through the use of interactive examples and instruction." /> 22 </head> 24 <body> 26 <h1>Welcome to Our Web Site!</h1> 28 <p>We have designed this site to teach about the wonders of <strong><em>XHTML</em></strong>. <em>XHTML</em> is better equipped than <em>HTML</em> to represent complex data on the Internet. <em>XHTML</em> takes advantage of XML’s strict syntax to ensure well-formedness. Soon you will know about many of the great new features of <em>XHTML.</em></p> Main.html The meta element provides information to search engines about the document. The name attribute describes the type of meta element. The content attribute provides the information search engines use to catalog pages.
53
Main.html 36 37 <p>Have Fun With the Site!</p> 38
</body> 40 </html> Main.html
54
1 <?xml version = "1.0"?> 2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" " 4 5 <!-- Fig. 5.9: index.html --> 6 <!-- XHTML Frames I > 7 8 <html xmlns = " <head> <title>Internet and WWW How to Program - Main</title> <meta name = "keywords" content = "Webpage, design, XHTML, tutorial, personal, help, index, form, contact, feedback, list, links, frame, deitel" /> 14 <meta name = "description" content = "This Web site will help you learn the basics of XHTML and Web page design through the use of interactive examples and instruction." /> 19 </head> 21 <!-- The <frameset> tag sets the frame dimensions > <frameset cols = "110,*"> 24 <!-- Individual frame elements specify which pages --> <!-- appear in a given frame > <frame name = “leftframe" src = "nav.html" /> <frame name = "main" src = "main.html" /> 29 Index.html The frameset element informs the browser that the page contains frames. The cols attribute gives the width of each frame. The first vertical frame created is 110 pixels from the left of the browser. The second vertical frame fills the rest of the browser, as indicated by the * value. Nav.html is loaded into the left frame and main.html is loaded into the right frame. The frame element loads documents into the frameset. The src attribute indicates the document to be loaded.
55
Left frame (leftframe)
<noframes> <p>This page uses frames, but your browser does not support them.</p> 33 <p>Please, <a href = "nav.html">follow this link to browse our site without frames</a>.</p> </noframes> 37 </frameset> 39 </html> The noframes element provides an option for browsers that do not display frames. Index.html Left frame (leftframe) Right frame (main)
56
Program Output When Header Examples is selected, the document it links to is displayed in the right frame.
57
The document will open in the frame called main.
1 <?xml version = "1.0"?> 2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " 4 5 <!-- Fig. 5.10: nav.html > 6 <!-- Using images as link anchors --> 7 8 <html xmlns = " 9 <head> <title>Internet and WWW How to Program - Navigation Bar </title> </head> 14 <body> 16 <p> <a href = "links.html" target = "main"> <img src = "buttons/links.jpg" width = "65" height = "50" alt = "Links Page" /> </a><br /> 22 <a href = "list.html" target = "main"> <img src = "buttons/list.jpg" width = "65" height = "50" alt = "List Example Page" /> </a><br /> 27 <a href = "contact.html" target = "main"> <img src = "buttons/contact.jpg" width = "65" height = "50" alt = "Contact Page" /> </a><br /> 32 Nav.html The target attribute specifies where the document linked by the anchor should display. The document will open in the frame called main.
58
33 <a href = "header.html" target = "main">
<img src = "buttons/header.jpg" width = "65" height = "50" alt = "Header Page" /> </a><br /> 37 <a href = "table1.html" target = "main"> <img src = "buttons/table.jpg" width = "65" height = "50" alt = "Table Page" /> </a><br /> 42 <a href = "form.html" target = "main"> <img src = "buttons/form.jpg" width = "65" height = "50" alt = "Feedback Form" /> </a><br /> </p> 48 </body> 50 </html> Nav.html Other values of target can be specified to load documents onto a new browser window, into the same frame that the anchor appears in and onto a full browser window, removing all frames.
59
The vertical frame on the right is divided into two horizontal frames.
1 <?xml version = "1.0"?> 2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" " 4 5 <!-- Fig. 5.11: index2.html --> 6 <!-- XHTML Frames II > 7 8 <html xmlns = " <head> <title>Internet and WWW How to Program - Main</title> 11 <meta name = "keywords" content = "Webpage, design, XHTML, tutorial, personal, help, index, form, contact, feedback, list, links, frame, deitel" /> 15 <meta name = "description" content = "This Web site will help you learn the basics of XHTML and Web page design through the use of interactive examples and instruction." /> 20 </head> 22 <frameset cols = "110,*"> <frame name = "nav" src = "nav.html" /> 25 <!-- Nested framesets are used to change the --> <!-- formatting and spacing of the frameset --> <!-- as a whole > <frameset rows = "175,*"> <frame name = "picture" src = "picture.html" /> <frame name = "main" src = "main.html" /> </frameset> 33 Index2.html The vertical frame on the right is divided into two horizontal frames. The rows attribute works in a similar manner to the cols attribute, except the rows attribute gives the height of each frame.
60
Index2.html Program Output
<noframes> <p>This page uses frames, but your browser does not support them.</p> 37 <p>Please, <a href = "nav.html">follow this link to browse our site without frames</a>.</p> </noframes> 41 </frameset> 43 </html> Index2.html Program Output The nested frame element splits the right vertical frame into two horizontal frames.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.