<base>: The HTML Base Element

1 Description

The HTML <base> element allows you to define a partial or full url which will be prepended to all relative urls found in the HTML document. The <base> element must have either a target attribute, or an href attribute, or both a target and href attribute.

The <base> element must appear prior to all elements which have an href attribute.

There may be, at most, one <base> element in an HTML document.

2 Examples

<!DOCTYPE html>
<html>
    <head>
        <title>Example Page</title>
        <base href="https://www.google.com">
    </head>
    <body>
        <h1>Google Products and Services</h1>
        <p>Below are some links to Google products and/or services.</p>
        <a href="/finance">Google Finance</a>
        <a href="/news">Google News</a>
        <a href="/images">Google Images</a>
    </body>
</html>

This document was last updated: