Example

A simple <base> tag:

Laboratory

description & Usage

The <base> tag is used to change the base URL value and target attribute for all relative addresses.

In the following code example we change all relative addresses of our HTML document from .com to .org and open them in a new page instead by:

<head>
     <base href="https://pnldev.org/" target="_blank">
</head>

What is a base URL? The base URL refers to the main domain address. It is attached to the beginning of all relative URLs within the HTML document.

For more information about relative addresses, refer to the 'File Addressing' page.

Notes

Note: The <base> element does not have a closing tag.

Note: The <base> tag must have either the href or target attribute.

Note: The <base> tag must be written inside the <head> tag.

Note: The href attribute of the <base> tag only affects relative addresses.

Browser compatibility and Support

# Chrome Edge Firefox Safari Opera
<base>

Global Attributes

The <base> tag supports the HTML Global Attributes.

Event Attributes

The <base> tag not supports the HTML Event Attributes.