HTML's BASE tag
A record of the original URL of the document: this allows you to
move the document to a new directory (or even a new site) and have
relative URLs access the appropriate place with respect to the
original URL.
If the BASE element is absent the document viewer assumes the base
URL to be the one it used to access the document.
The BASE element gives the base URL for dereferencing relative URLs,
using the rules given by the URL specification, e.g.
<BASE href="http://WDVL.Internet.com/index.html">
...
<IMG SRC="Icons/logo.gif" ALT="WDVL logo">
The image is deferenced to
http://WDVL.Internet.com/Icons/logo.gif
In the absence of a BASE element the document URL should be used.
Note that this is not necessarily the same as the URL used to request
the document, as the base URL may be overridden by an HTTP header
accompanying the document.
Example
<Head>
<Title>Interesting Pages on the Web</Title>
<Base href="http://WDVL.Internet.com/WDVL/Tour.html">
</Head>
The URL inside the href attribute points to the Tour.html itself.
The server will strip off the "Tour.html" bit, to get the directory,
and then complete relative URL's relative to that, e.g.
<Img src="Tour.gif" alt="button">
becomes
<Img src="http://WDVL.Internet.com/WDVL/Tour.gif" alt="button">
Doing this has the advantages that you can move a group of related
files around without breaking links by just changing the BASE; and
relative URL's make your HTML more readable, i.e. less clutter.
Note too that when you move over to another computer
you just need to change the domain name in one place.
Or, if you just move the one document, leave the BASE as it is,
and it will still reference the relative URLs correctly.
|