HTMLBaseElement: href property
Baseline Widely available
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.
Value
A string that contains a URL, or the empty string (""
) if the corresponding <base>
element does not include the href
attribute.
Examples
HTML with base URL
This example demonstrates that the href
attribute in <base>
is reflected in the href
property of HTMLBaseElement
.
HTML
html
<base href="https://developer.mozilla.org/example" />
JavaScript
js
const base = document.getElementsByTagName("base")[0];
log(`base.href="${base.href}"`);
Result
Specifications
Specification |
---|
HTML # dom-base-href |
Browser compatibility
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
href | ||||||||||||
data: and javascript: urls are not allowed | ||||||||||||
tab, newline, and < are not allowed (dangling markup prevention) |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- No support
- No support
- See implementation notes.
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.