base (HTML element)

Spec
Depr. Empty Version
No Yes HTML 2
Browser support (more…)
IE5.5+ FF1+ SA1.3+ OP9.2+ CH2+
Full Full Full Full Full

Syntax

<base href="uri"/>

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.

Example

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

<base href="http://lloydi.com" target="right"/>

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

Internet Explorer Firefox Safari Opera Chrome
5.5 6.0 7.0 8.0 1.0 1.5 2.0 3.0 3.5 1.3 2.0 3.1 4.0 9.2 9.5 10.0 2.0
Full Full Full Full Full Full Full Full Full Full Full Full Full Full Full Full Full

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

In this Section

User-contributed notes

Related Products