Join MDN and developers like you at Mozilla's View Source conference, 12-14 September in Berlin, Germany. Learn more at https://viewsourceconf.org

<base> Redirect 1

Summary

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

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 Empty; this is a void 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

Attributes

This element includes the global attributes.

href
The base URL to be used throughout the document for relative URL addresses. If this attribute is specified, this element must come before any other elements with attributes whose values are URLs.
Absolute and relative URIs are allowed (but see note section below).
target
A name or keyword indicating the default location to display the result when hyperlinks or forms cause navigation, for elements that do not have an explicit target reference. In HTML4, this is the name of, or a keyword for, a frame. In HTML5, it is a name of, or keyword for, a browsing context (for example, tab, window, or inline frame). The following keywords have special meanings:
  • _self: Load the result into the same HTML4 frame (or HTML5 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 HTML4 window or HTML5 browsing context.
  • _parent: Load the result into the HTML4 frameset parent of the current frame or HTML5 parent browsing context of the current one. If there is no parent, this option behaves the same way as _self.
  • _top: In HTML4: Load the result into the full, original window, canceling all other frames. In HTML5: 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.

Examples

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

Specifications

Specification Status Comment
WHATWG HTML Living Standard Living Standard  
HTML5 Candidate Recommendation  
HTML 4.01 Specification Recommendation  

Browser compatibility

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

Notes

  • The base URL of a document can be queried from a script using document.baseURI.
  • Support of relative URIs for href was added in Gecko 2.0 (Firefox 4.0)
  • HTML 2.0 and 3.2 define only the href attribute
  • XHTML requires a trailing slash: <base />

Document Tags and Contributors

 Contributors to this page: Sheppy
 Last updated by: Sheppy,