English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The HTML <base> tag defines a base URL, which is used for all relative URLs in the HTML document. Only one <base> tag can be used in a document, and it must be defined within the <head> tag. The <base> tag should appear in the document before any relative URL is used. This tag is also commonly referred to as the <base> element.
Specify the default URL and default target for all links on the page:
<!doctype html> <html> <head> <meta charset="UTF-8"> <title>HTML5 Base by www.oldtoolbag.com</title> <base href="https://www.oldtoolbag.com/html/"> </head> <body> <h1>Heading 1</h1> <a href="html-tutorial.html">HTML Tutorials</a> </body> </html>Test it out ‹/›
IEFirefoxOperaChromeSafari
All mainstream browsers support the <base> tag.
The <base> tag specifies a default URL or default target for all relative links on the page.
In a document, at most one <base> element can be used. The <base> tag must be within the <head> element.
The HTML <base> element is located within the <head> tag.
Only one <base> tag can be defined in a document. If there are multiple, only the first href and target value will be used.
Note: If the <base> tag is used, it must have an href attribute or a target attribute or both attributes.
None.
In HTML, the <base> tag does not have a closing tag.
In XHTML, the <base> tag must be closed correctly.
Attribute | Value | Description |
---|---|---|
href | URL | specifies the base target for relative URLs within the page. It can be an absolute URL or a relative URL. For example: href ="https://www.oldtoolbag.com/html/" href ="/html/" href ="html/" |
target | _blank _parent _self _top framename | specifies the location where the linked resource is displayed. It can be one of the following values: _self, _blank, _parent, _top _self-means resources are loaded into the current frame or context _blank-means resources are loaded into a new window or context _parent-means resources are loaded into the parent frame or context _top-representing resources loaded into the entire original window |
The <base> tag supports Global Attributes of HTML.
The <base> tag does not support any event attributes.
HTML DOM Reference Manual: Base Object