Why did the arrival of hypertext links make such a difference? You can understand it better by comparing the Internet to a vast library. What if you went into a library and discovered that the only way you could find anything was by going through multiple lists of items, each one becoming a little more specific, until you narrowed your search down to the information you were looking for? Then, when you found the book you wanted, you had to access the information in it, page by page, until you found what you needed? Thankfully, libraries don’t work that way. But, if you’ve ever used a gopher server, that’s about what it’s like.
The development of HTML and the creation of the World Wide Web made it possible to go right to the document you want—and a lot more. Because pages are linked together, it is possible to go to the specific page you want. Even better, assuming a link is provided, it is possible to go to a precise location on the page you are looking for. And with all those pages linked together around the world…well, you see where the term web comes from. And it’s all possible because of hypertext.
What is hypertext? Even if you’ve never been on the Web, you’ve probably used hypertext before. Often the help files of computer programs use hypertext to help you quickly find the answer to your question. Computerized encyclopedias are another place you’ve probably encountered hypertext. The articles in such encyclopedias and dictionaries generally have related subjects listed at the bottom. If you click on the subject, you are instantly transported to another article for more information. That’s hypertext at work. To understand how to use it on the Web, you must learn a little about uniform resource locators (URLs). URLs are more commonly known as Web addresses, Internet addresses, and even “dot.coms.” But simplistic names won’t give you an idea of how a URL works.
A URL is made up of several parts, each of which helps identify a specific location where a resource can be found (or sent). For example, if you want to visit Osborne’s Web site, the address would be http://www.osborne.com/. The first part of the address is the protocol, usually http://. This stands for Hypertext Transfer Protocol, the specification for transferring documents using hypertext links or hyperlinks. As you’ll see in the following, there are other protocols, depending on what you are trying to do on the Net, but the primary one for the Web is http://. When an Internet server sees http:// at the beginning of an address, it knows to expect an HTML document.
The next portion of a URL identifies the host (also called a server). In the case of Osborne’s address, the host portion is www.osborne.com. The host is the system where the file or document you are looking for can be found or where it is to be sent. You probably are more familiar with the term domain name, as in www.domainname.com. When you type in a domain name, it is translated into what is known as an IP address, which numerically describes the exact location of the server that hosts that particular Web site (see Chapter 7 for more information on IP addresses).
The last part of a URL locates the file on the server. You generally don’t have to type in this part because the browser supplies it for you. If it is displayed, the file location might look something like this:
No directory is listed in this address because the index page is usually located in a site’s main, or root, directory. If you are accessing a page that is in a different directory on a Web site, the address might display this way:
In the case of this address, the file is pictures.htm; it resides in the vacations directory.
If you know the filename and directory of the page you are looking for, you can go straight to it without having to visit the site’s home page. Just type in the complete address, including directory and filename, and you’ll take a shortcut to the page.
A complete URL points to a specific resource on the Internet by identifying the protocol://host/directory/filename.ext.
Because you normally go to the first, or root, directory when you visit a Web site, you might not always see a directory listed in the URL.
Table 5-1 shows how URLs change to reflect the action you are requesting.
To access a Web site
To access a secure Web site
To use File Transfer Protocol
To use the Mailto Protocol
To access a newsgroup
To use a Gopher server
To access a local file (on your computer)
Hypertext points to a precise location on the Internet by using a URL to identify where information is and what should be done with it. But how do you create the link? That’s where HTML comes in. HTML stands for Hypertext Markup Language. You can create hypertext links or hyperlinks using an element specially designed for that purpose: the anchor element, <a> </a>.
A link is simply a connection between one hypertext document and another created by enclosing text or an image inside two anchor tags. However, the link must point somewhere, so you also must include the href attribute. Href stands for hypertext reference and is the place where you put the URL or pointer so your link has a destination. A link that doesn’t point anywhere will look like this:
<a href=" ">This link doesn't go anywhere</a>.
If you type this link into a Web page, it will appear as the default blue underlined text that characterizes links, but it won’t take you anywhere because it doesn’t have an address. To give the link somewhere to take you, insert a URL between the quotation marks beside the href attribute. To make the link take a visitor to Osborne’s site, change the link to read:
<a href="http://www.osborne.com">Go to Osborne's Web site.</a>
Create an HTML file from your template and try typing these lines in. You should see a pair of links that looks like this:
That’s all there is to creating a simple link to another Web site. Oh, but there’s so much more you can do with them.