This reference is built into PageRIJ — a live HTML, CSS & SVG authoring and learning environment.

HTML <base> element

The <base> element sets the document base URL for resolving relative addresses, the default target for hyperlinks and form submissions, or both. It belongs in the <head> element.

The href attribute supplies the base URL. With href="https://example.com/docs/", the relative address chapter-1.html resolves to https://example.com/docs/chapter-1.html. The trailing slash matters: it identifies docs/ as the directory against which that filename is resolved.

This also affects fragment links. With the same base, href="#details" resolves to https://example.com/docs/#details, which may refer to a different document from the current page. Fully specified absolute URLs retain their own address.

The target attribute supplies the default browsing target. For example, target="_blank" requests a new tab or window. An explicit target on an <a> or <form> element overrides this default for that element.

A document may contain at most one <base>, and it must have href, target, or both. A base with href must precede other elements with URL-valued attributes; one with target must precede elements representing hyperlinks. Place it early in the head to establish these settings before they are used.

The element has no contents or closing tag. The example shows URL resolution only; the <base> declaration itself has no visual representation.

Attributes: href, target, GLOBALS.

Typical layout:
<head>
  <base href="https://example.com/docs/">
</head>

<body>
  <a href="chapter-1.html">Chapter 1</a>
</body>
Visual representation:

None

Resolved link address:
https://example.com/docs/chapter-1.html