Links and anchors enable you to connect documents to one another. There are three kinds of connections:
Every link begins the same way. You must write a tag that hotwires a document. Everything after this tag, whether an image or text, will be blue and underlined. If someone clicks that hotwired material, Netscape will take them to another document or a particular location.
Connecting two documents in the same directory.
To begin the hotwiring, type the following tag:
<a href="file.html">
"file.html" refers to another document in the same directory. Remember that this tag is case-sensitive, so make certain that capital and lower-case letters are the same as they appear in the actual document name.
Technically speaking, whatever follows this tag will be the link. The tag itself will not connect the documents. Instead, people must have some clickable material in order to make the connection. After you have inserted that material, whether text or an image tag, type the following:
</a>
This tag ends the hotwiring.
For example, if you were writing a file called "home.html" and you wanted people to construct a link to a file called "document.html", you might write the following:
Click <a href="document.html">here</a> to read another document.
The word "here" will be blue and underlined.
In addition to connecting two documents, you can also connect one file to an image. Remember that Netscape cannot incorporate jpg images into a text document. So people will often include a thumbnail gif image which acts as a link to a jpg. For example:
Click this image <a href="image.jpg"><img src="image.gif"></a> to see a larger, jpg version.
The gif image will appear on the screen with a blue outline. If someone clicks on it, Netscape will display the jpg.
Connecting two documents in different directories.
This sort of link works much the same way as connecting documents in the same directory. You just have to provide some more information. Start the tag the same way, but rather than inserting just the file name, you need to include the whole URL (the World Wide Web address that you would use to read any document in Netscape).
Let's use the same example, where you are connecting "home.html" to "document.html." Except this time, "document.html" is on the main UVa Web directory. The tagging structure would read as follows:
Click <a href="http://www.virginia.edu/document.html">here</a> to read another document.
Connecting one part of a document to a particular location within a document.
This is the most complicated sort of connection you are likely to create. It involves not only a link (a tag saying where you want to connect), but an anchor, which says where you want to go. With links between documents, you do not need to designate a particular location; Netscape simply goes to the beginning. In this case, you must say where you want to go.
The process begins like other links, with an <a href=" "> tag. But the space between quotation marks includes a # and some sort of indicator, any number, word, or letter. You will use this number, word, or letter again later in the document.
Now move to the place in the document where you want link to go. Type the following tag:
<a name= >
The space after the = sign should be the same number, word, or letter that you used in the link.
Here's an example. Suppose you wanted to begin a document with a table of contents that would link people to text that appear s later in the document. Your index would include the following:
<a href="#pt1">Part I</a> <a href="#pt2">Part II</a>
Later in the document, you will include the following tags:
<a name=pt1></a> and <a name=pt2></a>
The <a name=pt1></a> tags should appear at the beginning or Part I. If someone clicks on the link, Netscape will automatically go to the anchor tag.
These anchor tags can appear anywhere in the document. All they do is tell Netscape where to go when someone clicks on the initial linking tag.
In addition to linking part of a document to another part of that same document, you can link one document to part of another document in the same directory, or to a document in another directory. To do this you will combine the various principles of links and anchors. For example, if you wanted to connect some text in "home.html" to a particular place in "document.html", you would write the following:
Click <a href="document.html#pt1>here</a> to see Part I.
At the beginning of part one on "document.html," you would write the following:
<a name=pt1>
The process would be very similar if you were linking to a document in another directory. Again borrowing from the earlier example, your tag would be as follows:
Click <a href="http://www.virginia.edu/document.html#pt1>here</a 62; to see Part I.