ptg16476052
98 LESSON 6: Working with Links
I can explain this better with an example. Let’s say that your site consists of two sections,
/stuff and /things. If you want to link from the file index.html in /stuff to
history.html in /stuff (or any other file in /stuff), you use a relative link. That way,
you can move the /stuff directory around without breaking any of the internal links. On
the other hand, if you want to create a link in /stuff/index.html to /things/
index.html, an absolute link is probably called for. That way, if you move /stuff to
/more/stuff, your link will still work.
The rule of thumb I generally use is that if pages are part of the same collection, I use
relative links, and if they’re part of different collections, I use absolute links.
Links to Other Documents on the Web
So , now you have a whole set of pages on your local disk, all linked to each other. In
some places in your pages, however, you want to refer to a page somewhere else on
the Internet—for example, to The First Caesars page by Dr. Ellis Knox at Boise State
University for more information on the early Roman emperors. You also can use the link
tag to link those other pages on the Internet, which I’ll call remote pages. Remote pages
are contained somewhere on the Web other than the system on which you’re currently
working.
The HTML code you use to link pages on the Web looks exactly the same as the code
you use for links between local pages. You still use the <a> tag with an href attribute,
and you include some text to serve as the link on your web page. Rather than a filename
or a path in the href, however, you use the URL of that page on the Web, as Figure 6.5
shows.
URL of remote file
Closing tag
<A HREF="http://www.cern.ch/">Cern Home Page</A>
Opening tag
FIGURE 6.5
Link to remote
files.