If you've surfed the Web at all, you should be familiar with hypertext links. You may have read or heard them referred to as hyperlinks, hotlinks, or links. You've probably used hypertext links not only to jump to and view another Web page or jump to a specific place in either the same or another Web page, but also to display an image, download a program, send an e-mail message, play an audio or video clip, run a script, access a database, and so on. You can use hypertext links to jump to anything that has an address on the Internet (not just on the Web), as long as you don't need a password. Of course, what happens after you make the jump depends on where you go.
The A (Anchor) element is used to create a hypertext link, with its start and end tags bracketing the text that needs to be clicked on to activate the link. To create a link, an HREF attribute needs to be included in the A element's start tag, specifying the Web address (or URL) of the object that is being linked. Here is the general format of a hypertext link when inserted in a Web page:
<a href="address of the linked object">text to be displayed as the link</a>
Turn the phrase "urban horticulture" into a hypertext link that connects to the home page of the University of Washington's Center for Urban Horticulture (remove the I element start and end tags you added previously; see Figure 2.8).
<p>Welcome to my world! My name is <i><b>Miranda Jones</b></i>. I'm a sophomore at Excelsior College, majoring in <a href="/">urban horticulture</a>. When not studying, my favorite activity is <em>inline skating</em>, which is <b>great exercise</b>, but also a lot of <strong>fun</strong>.
You will need to be connected to the Internet to test out the link. After visiting the linked page, just click the Back button to return to the example page.
It used to be considered proper netiquette to request permission before linking to someone else's Web site or page. One of the reasons for this was the skimpy traffic allowances and bandwidth restrictions that were typical not that long ago.These days, however, most people want to get as many links to their sites as they can (within reason, of course). It is a good policy, however, to notify the author or owner when you link to a site or page, which enables you to ask for a link in return (a reciprocal link).
A commonly used device for creating a hypertext link is the "click here" link, which might be displayed in a page as "Click here to visit the Center of Urban Horticulture" or "To visit the Center of Urban Horticulture, click here." This way of linking should be avoided, however. For one thing, many search engines pay attention to the content of links on your page when indexing your page, with "click here" or "click me" providing them with nothing they can index. A much better way of doing this is to simply create the link in this form: "Visit the Center of Urban Horticulture."
The Web address that a hypertext link connects with is also called a URL (Uniform Resource Locator). A URL may be composed of several parts, including:
The Protocol. This specifies the protocol required to connect to the linked object. For instance, when creating a link that connects to http://depts.washington.edu/urbhort/index.html, the http: part requests that the object be transferred using HyperText Transfer Protocol (HTTP). The two forward slashes (//) indicate that the resource being accessed is hierarchically organized (in folders and subfolders).
Alias/Domain or IP Address. This specifies the location of a server or site on the Web. For instance, in www.yahoo.com, www is the alias and yahoo.com is the domain. An alias is a shortcut to another location within a domain. In the previous URL example, depts is the alias, whereas washington.edu is the domain. Alternatively, an IP address (such as 220.127.116.11) may also be used to connect to a server on the Web.
Port Number (Optional). You only need to include a port number in a URL if the resource you are connecting to uses a port number other than the default. For instance, if a domain, www.somewhere.com, is using a port number of 81, it would be included in the URL like this: www.somewhere.com:81/.
Folder/File Path. This specifies the path in a site that leads to the linked object. It might be simply a file name (such as mypage.html in http://www.somewhere.com/mypage.html, for instance), or it may be a folder path that points to the location of an object within a site (such as myfolder/mypage.html in http://www.somewhere.com/myfolder/mypage.html).
On Web servers, the file name index.html is usually designated as an "index" page. This enables you to leave off the index page's file name in a URL, if you want. For instance, http://www.myserver.com/index.html and http://www.myserver.com/ represent the same URL.You can create index files not only in your root folder, but also in any other folder in your site. (This only works on a Web server, however—it doesn't work on your local machine.)