HTML <base> Tag
Example
<head>
<base href="/html/">
</head>
<body>
<img src="smiley.png" alt="smiley">
</body>
Meaning
The <base> element located within the head element specifies the base URL to be used for all relative URLs contained within a document.
Notes:
- There can only be only one <base> element in a document, and it must be inside the <head> element.
- HTML 2.0 and 3.2 define only the href attribute.
If the document has no <base> elements, then baseURI defaults to location.href.
Warning: The <base> element must come before other elements with attribute values of URLs, such as <link>'s href attribute.
Usage Notes:
Note 1: If multiple <base> elements are used, only the first href and first target are obeyed — all others are ignored.
Note 2: Open Graph tags do not acknowledge <base>, and should always have full absolute URLs. For example:
<meta property="og:image" content="https://example.com/thumbnail.jpg" />
Version: HTML 2, 3.2, 4, 4.01, 5
Standard Syntax
<base href="URL" target="_blank | _parent | _self | _top">
Browser Support
Status
Attributes
Attribute | Value | Description |
---|---|---|
href | URL | Hyperlink of the page used to all relative URLs in the page |
target | _blank _parent _self _top |
This attribute specifies the target window for a hypertext source link that references frames. |
Global Attributes
<base> element also supports the Global Attributes in HTML.
Event Attributes
<base> element also supports the Event Attributes in HTML.
By Default CSS Value(s)
None