HTML - <base>

The HTML <base> element specifies the base URL to use for all relative URLs contained within a document. There can be only one <base> element in a document. 

Example

 

HTML
<base href="http://www.example.com/page.html">
<base target="_blank" href="http://www.example.com/page.html">  

Description  

The HTML <base> element specifies the base URL to use for all relative URLs contained within a document. There can be only one <base> element in a document. 

The base URL of a document can be queried from a script using document.baseURI.

Usage Note: If multiple <base> elements are specified, only the first href and first target value are used; all others are ignored.
Content categories Metadata content.
Permitted content None, it is an empty element.
Tag omission There must be no closing tag.
Permitted parent elements Any <head> that doesn't contain any other <base> element
DOM interface HTMLBaseElement

Browser Compatibility  

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support (Yes) 1.0 (1.7 or earlier) [1] (Yes) [2] (Yes) (Yes)
Feature Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support (Yes) 1.0 (1.0) [1] (Yes) (Yes) (Yes)

[1] Support of relative URIs for href was added in Gecko 2.0 (Firefox 4.0)

[2] Before Internet Explorer 7, <base> could be positioned anywhere in the document and the nearest value of <base> was used. Support for relative URLs has been removed in Internet Explorer 8

Specifications  

Specification Status Comment
WHATWG HTML Living Standard
The definition of '<base>' in that specification.
Living Standard No change since last snapshot.
HTML5
The definition of '<base>' in that specification.
Recommendation Specified the behavior of target
HTML 4.01 Specification
The definition of '<base>' in that specification.
Recommendation Added the target attribute

License

© 2016 Mozilla Contributors
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-us/docs/web/html/element/base

Element HTML HTML document metadata Reference Web