HTML <base> Tag
The <base> tag has recently become part of HTML5. It defines an absolute (base) URL for all the relative URLs in the HTML document. This tag also determines how links in the current document must be opened (in a new window, in the current window, etc.).
You can access the used base URL of a document from scripts with document.baseURI. If the document doesn’t contain any <base> element, baseURL will default to document.location.href.
The <base> tag is empty, which means that the closing tag isn’t required. But in XHTML, the (<base>) tag must be closed (<base/>).
Example of the HTML <base> tag: ¶
<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>
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.
The <base> tag must necessarily contain either href or target attribute. If necessary, you can use both attributes.
|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.|
| || || || || |