CKTIS / HTML
base — document base URL and default navigation target
The `base` element sets the document base URL through `href` and the default navigation target through `target`. It belongs in `head`, with at most one per document.
Version: WHATWG HTML Living Standard; index snapshot date recorded separately
Syntax
<base href="URL" target="TARGET">base is a metadata element in head. It requires href, target, or both attributes. It has no contents and no end tag in HTML.
href establishes the base for resolving relative URLs. Place this base before other elements with URL-valued attributes. The trailing / matters: the base https://example.com/docs/ with guide.html produces https://example.com/docs/guide.html.
target sets the default destination for links and forms; their own target overrides it. When base has target, it must precede all elements representing hyperlinks.
A document may contain at most one base. With invalid duplicates, browsers use the first href and first target independently. Beware: changing the base also affects relative fragment links such as #section, not just file paths.
Examples
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Base URL demo</title>
<base href="https://example.com/docs/" target="_self">
</head>
<body>
<a id="guide" href="guide.html">Guide</a>
<pre id="result"></pre>
<script>
document.getElementById('result').textContent =
document.getElementById('guide').href;
</script>
</body>
</html>Result
https://example.com/docs/guide.html
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.