Skip to: content, navigation

by Ian Lloyd

base (HTML element)

Spec
Depr. Empty Version
No Yes HTML 2
Browser support full matrix
IE5.5+ FF1+ Saf1.3+ Op9.2+
Full Full Full Full

Example

This markup sets my personal site as the base for all URLs in the document:

<base href="http://lloydi.com" target="right"/>
Type
head element
Contains
nothing
Contained by
head

Description

The base element, which is contained in the head of the document, provides a method for defining the base URL for all links and form submissions on a page. It also provides a common target (in the form of a named window) for all of these links or form submissions.

This element isn’t used very often these days, as making links is usually a simple case of creating links to documents relative to the web server root, like so:

I've published my <a href="/travel-writing/">holiday diaries</a>,
    including the <a href="/travel-writing/prague/2006/day2.html">crazy
    bone church at Kutna Hora</a>

When the links are accessed, the server will look for the document’s reference in the domain root, regardless of the location of the page that contains these links. It doesn’t matter one iota whether the referencing page is in the web server’s document root folder, or ten directory levels down—the server still looks in the root because the links begin with a "/" character.

Use This For …

Using the "/" character to signify a link relative to the server’s document root is fine, provided you’re running the pages from a server. However, there are many scenarios where this isn’t going to be the case—documents that are installed and run locally (for example, a set of help files that are installed on a machine) will not work with this technique. The base element allows you achieve the effect of smaller link href attributes by supplying a domain and even subdirectories.

The base element is only going to be useful to you if all your relative links or form submissions go to the same location. If your web page contains a mixture of links to different domains or subdirectories on the same server, the base element will be a hindrance, not a help.

Compatibility

IE5.5Full
6.0Full
7.0Full
Firefox1.0Full
1.5Full
2.0Full
Safari1.3Full
2.0Full
3.0Full
Opera9.2Full
9.5Full

It causes no compatibility issues, and has excellent support across all tested browsers.

In this Section

Related Reading

User-contributed notes

Add a note

To post a note on this topic, please log in with your SitePoint username and password. If you don't have an account yet, you can create a new account for free.

Related Products

The Principles of Beautiful Web Design

Best Seller!

You don’t need to go to Art School to design great looking web sites!

Book Cover: The Principles of Beautiful Web Design

Download the FREE sample chapters