Learning HTML 3.2 by Examples, section 5 Descriptions of HTML 3.2 tags:

BASE - base for URLs


To define base URL for relative URLs in the document (e.g. in HREF attributes of A elements). This is typically used when mirroring documents.

For example, given
<BASE href="http://foo.example.com/index.html">
the IMG element
<IMG SRC="images/bar.gif" ALT="">
refers to image

Typical rendering

None. The BASE element has no direct effect on the rendering of a document.

Basic syntax


Possible attributes

attribute name possible values meaning notes
HREF URL base URL to be used obligatory; must be absolute

Allowed context

The head element, in which at most one BASE element may appear.




<BASE HREF="http://www.cs.tut.fi/~jkorpela/HTML3.2/">

This implies that e.g. the link
<A HREF="lists.html">list examples</A>
is equivalent to
<A HREF="http://www.cs.tut.fi/~jkorpela/HTML3.2/lists.html">list examples</A>


The BASE element is, with few exceptions, useful only to make mirroring easier. Suppose there is a document which contains link tags like <A HREF="foo.html"> and suppose the document is copied to another server without the documents to which it refers that way. Then you can add a BASE element (referring to the original document) to the copy.

Since only one BASE element per document is allowed, you cannot have different base URLs in different parts of an HTML file.

In the absence of a BASE element in a document, the URL of the document itself is the base URL within it. (This is not necessarily the same as the URL used to request the document, since the base URL may be overridden by an HTTP header accompanying the document.)

It is advisable to enclose the URL in quotes, although this is not always mandatory.

Don't forget the slash "/". Anything that follows the last slash in the URL in a BASE element is interpreted as belonging to the filename part and ignored. The following is equivalent to the BASE element in the example above:
<BASE HREF="http://www.cs.tut.fi/~jkorpela/HTML3.2/foobar">
whereas the following are equivalent to each other, so the meaning of the first one is probably not what was intended:
<BASE HREF="http://www.cs.tut.fi/~jkorpela/HTML3.2">
<BASE HREF="http://www.cs.tut.fi/~jkorpela/">

Date of last update: 2010-12-16.
This page belongs to the free information site IT and communication, section Web authoring and surfing, by Jukka "Yucca" Korpela.