This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
The href property of the HTMLBaseElement interface contains a string that is the URL to use as the base for relative URLs.
It reflects the href attribute of the <base> element.
A string that contains a URL, or the empty string ("") if the corresponding <base> element does not include the href attribute.
This example demonstrates that the href attribute in <base> is reflected in the href property of HTMLBaseElement.
<base href="https://developer.mozilla.org/example" />
const base = document.getElementsByTagName("base")[0];
log(`base.href="${base.href}"`);
| Specification |
|---|
| HTML> # dom-base-href> |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
href |
1 | 12 | 1 | ≤12.1 | 3 | 18 | 4 | ≤12.1 | 1 | 1.0 | 4.4 | 1 |
forbid_data_javascript_urls |
No | No | 127 | No | 17.2 | No | 127 | No | 17.2 | No | No | 17.2 |
forbid_special_characters |
61 | 79 | 128 | 48 | 16 | 61 | 128 | 45 | 16 | 8.0 | 61 | 16 |
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/HTMLBaseElement/href