MDN Web Docs

<base>: The Document Base URL element

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.

Attributes

This element supports the global attributes as well as the following element-specific attributes:

href: URL

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 URLs are allowed.

target: String

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. 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 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 this attribute is specified, this element must come before any other elements with attributes whose values are URLs.

Usage notes

If multiple <base> elements are specified, only the first href and first target value are used; all others are ignored.

Examples

This example shows two uses of the <base> element, one of which also uses the target attribute.

HTML

<base href="http://www.example.com/page.html">
<base target="_blank" href="http://www.example.com/page.html">
DesktopMobile
ChromeEdgeChromeEdge
video3Yes?No