The <base>
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
.
Content categories | Metadata content. |
---|---|
Permitted content | None, it is an empty element. |
Tag omission | There must be no closing tag. |
Permitted parents | Any <head> that doesn't contain any other <base> element |
Permitted ARIA roles | None |
DOM interface | HTMLBaseElement |
This element's attributes include the global attributes.
href
target
_self
: Load the result into the same browsing context as the current one. This value is the default if the attribute is not specified._blank
: Load the result into a new unnamed browsing context._parent
: Load the result into the parent browsing context of the current one. If there is no parent, this option behaves the same way as _self
._top
: Load the result into the top-level browsing context (that is, the browsing context that is an ancestor of the current one, and has no parent). If there is no parent, this option behaves the same way as _self
.If multiple <base>
elements are specified, only the first href and first target value are used; all others are ignored.
<base href="http://www.example.com/page.html"> <base target="_blank" href="http://www.example.com/page.html">
Specification | Status | Comment |
---|---|---|
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 |
Feature | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|---|
Basic support | Yes | Yes | 1 | Yes1 | Yes | Yes |
href |
Yes | Yes | 1 | Yes | Yes | Yes |
target |
Yes | Yes | Yes | Yes | Yes | Yes |
Feature | Android webview | Chrome for Android | Edge mobile | Firefox for Android | IE mobile | Opera Android | iOS Safari |
---|---|---|---|---|---|---|---|
Basic support | Yes | Yes | Yes | 4 | Yes | Yes | Yes |
href |
Yes | Yes | Yes | 4 | Yes | Yes | Yes |
target |
Yes | Yes | Yes | Yes | Yes | Yes | Yes |
1. Before Internet Explorer 7, <base>
can be positioned anywhere in the document and the nearest value of <base>
is used.
<a href="#anchor">anchor</a>
is resolved by using the base url as reference and triggers an http request to the base url.<base href="http://www.example.com/">
<a href="#anchor">Anker</a>
http://www.example.com/#anchor
OpenGraph meta-tags do not acknowledge base-url and should always have full URLs. For example:
<meta property='og:image' content='http://example.com/thumbnail.jpg'>
© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base