Linking

 

The chief power of HTML comes from its ability to link text and/or an image to another document or
section of a document. A browser highlights the identified text or image with color and/or underlines
to indicate that it is a hypertext link (often shortened to hyperlink or just link).

HTML's single hypertext-related tag is <A>, which stands for anchor. To include an anchor in your
document:

1.start the anchor with <A (include a space after the A)
2.specify the document you're linking to by entering the parameter HREF="filename" followed by
a closing right angle bracket (>)
3.enter the text that will serve as the hypertext link in the current document
4.enter the ending anchor tag: </A> (no space is needed before the end anchor tag)

Here is a sample hypertext reference in a file called US.html:

<A HREF="MaineStats.html">Maine</A>

This entry makes the word Maine the hyperlink to the document MaineStats.html, which is in the
same directory as the first document.

Relative Pathnames Versus Absolute Pathnames

You can link to documents in other directories by specifying the relative path from the current
document to the linked document. For example, a link to a file NYStats.html located in the
subdirectory AtlanticStates would be:

<A HREF="AtlanticStates/NYStats.html">New York</A>

These are called relative links because you are specifying the path to the linked file relative to the
location of the current file. You can also use the absolute pathname (the complete URL) of the file,
but relative links are more efficient in accessing a server. They also have the advantage of making
your documents more "portable" -- for instance, you can create several web pages in a single folder
on your local computer, using relative links to hyperlink one page to another, and then upload the
entire folder of web pages to your web server. The pages on the server will then link to other pages
on the server, and the copies on your hard drive will still point to the other pages stored there.

It is important to point out that UNIX is a case-sensitive operating system where filenames are
concerned, while DOS and the MacOS are not. For instance, on a Macintosh, "DOCUMENT.HTML",
"Document.HTML", and "document.html" are all the same name. If you make a relative hyperlink to
"DOCUMENT.HTML", and the file is actually named "document.html", the link will still be valid. But if
you upload all your pages to a UNIX web server, the link will no longer work. Be sure to check your
filenames before uploading.

Pathnames use the standard UNIX syntax. The UNIX syntax for the parent directory (the directory that
contains the current directory) is "..". (For more information consult a beginning UNIX reference text
such as Learning the UNIX Operating System from O'Reilly and Associates, Inc.)

If you were in the NYStats.html file and were referring to the original document US.html, your link
would look like this:

<A HREF="../US.html">United States</A>

In general, you should use relative links whenever possible because:

1.it's easier to move a group of documents to another location (because the relative path
names will still be valid)
2.it's more efficient connecting to the server
3.there is less to type

However, use absolute pathnames when linking to documents that are not directly related. For
example, consider a group of documents that comprise a user manual. Links within this group
should be relative links. Links to other documents (perhaps a reference to related software) should
use absolute pathnames instead. This way if you move the user manual to a different directory, none
of the links would have to be updated.

URLs

The World Wide Web uses Uniform Resource Locators (URLs) to specify the location of files on other
servers. A URL includes the type of resource being accessed (e.g., Web, gopher, FTP), the address
of the server, and the location of the file. The syntax is:

scheme://host.domain [:port]/path/ filename

where scheme is one of :

Home