F.6. Linking
One of the most important XHTML features is the hyperlink, which references (or links to) other resources, such as XHTML documents and images. In XHTML, both text and images can act as hyperlinks. Web browsers typically underline text hyperlinks and color their text blue by default, so that users can distinguish hyperlinks from plain text. In Fig. F.5, we create text hyperlinks to four different Web sites.
Figure F.5. Linking to other Web pages.
Line 17 introduces the strong element. Browsers typically display such text in a bold font. Links are created using the a (anchor) element. Line 20 defines a hyperlink that links the text Deitel to the URL assigned to attribute HRef, which specifies the location of a linked resource, such as a Web page, a file or an e-mail address. This particular anchor element links to a Web page located at http://www.deitel.com. When a URL does not indicate a specific document on the Web site, the Web server returns a default Web page. This page is often called index.html; however, most Web servers can be configured to use any file as the default Web page for the site. (Open http://www.deitel.com in one browser window and http://www.deitel.com/index.html in a second browser window to confirm that they are identical.) If the Web server cannot locate a requested document, it returns an error indication to the Web browser, and the browser displays a Web page containing an error message to the user.
Anchors can link to e-mail addresses using a mailto: URL. When someone clicks this type of anchored link, most browsers launch the default e-mail program (e.g., Outlook Express) to enable the user to write an e-mail message to the linked address. Figure F.6 demonstrates this type of anchor. Lines 1719 contain an e-mail link. The form of an email anchor is <a href="mailto:</tt><span>emailaddress</span><tt>">...</a>. In this case, we link to the e-mail address deitel@deitel.com.
Figure F.6. Linking to an e-mail address.
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 My e-mail address is 17 <a href="</span"> "mailto:deitel@deitel.com"></a><a href="</span"> 18 deitel@deitel.com 19 </a> 20 . Click the address and your browser will 21 open an e-mail message and address it to me. 22 23 24 |
F 7 Images
|