This website uses cookies

We use cookies to personalize content and ads, to provide social media features and to analyse our traffic. We also share information about your use of our site with our social media, advertising and analytics partners who may combine it with other information that you've provided to them or that they've collected from your use of their services. Please read more at our privacy policy page.



HTML <base> Tag

The <base> tag has recently become part of HTML5. It specifies an absolute (base) URL for all relative URLs in the HTML document. The tag also determines how links in the current document should be opened (in a new window, in the current window, etc.).

Syntax

The <base> tag has no end tag in HTML, but in XHTML the end tag (</base>) is required.

Only one <base> tag can be used on the page, and it must be placed in the <head> element. You must insert it as soon as possible, since its action extends from the place where it is specified.

Example

<!DOCTYPE html>
<html>
  <head>
    <title>HTML base tag</title>
    <base href="https://www.w3docs.com/" target="_blank">
  </head>
  <body>
    <a href="/css3-maker/border-radius">Try CSS Maker Tool</a>
  </body>
</html>

Result

In this example, the <base> tag defines the base URL - "https://www.w3docs.com/", and the relative link "/css3-maker/border-radius" will use that URL as a starting point.

Copy the above-mentioned code into our editor, and you will see an active link, which, when clicked, opens in a new window. Although the link itself does not contain the target _blank attribute, it will open in a new window, since we have set the target _blank attribute to the absolute URL in the <base> tag.

Attributes

The <base> tag must necessarily contain either href or target attribute. If necessary, you can use both attributes.

Attribute Value Definition
href URL Specifies the base URL for all relative URLs of the page. The default base address is substituted before all relative addresses on the page.
target _blank Opens the link in a new window.
_self Opens the link in the current window.
_parent Opens the link in the parent frame.
_top Opens the document in the full width of the page.

Browser support