The <base> tag defines the base URL for all relative links on a page.
Its purpose is to simplify and shorten relative links.
A page can have one <base> tag and must be inside the <head> tag.
A <base> tag inside the head tag.
All relative URLs start with https://www.company.com/public/.
<head>
<base href="https://www.company.com/public/">
</head>
Note: The <base> element must be placed before any element with a URL reference, such as <link>.
A <base> tag that makes all relative links use the base URL https://en.wikipedia.org/wiki/.
Note how it shortens the relative URLs in the HTML.
<head>
<base href="https://en.wikipedia.org/wiki/">
</head>
<nav>
<a href="Vincent_van_Gogh">Vincent Van Gogh</a> <br />
<a href="Henri_Matisse">Henri Matisse</a> <br />
<a href="Paul_Cézanne">Paul Cézanne</a>
</nav>
Note: The <base> element also shortens the URLs on the src attribute used in image, audio, video, and others.
This table lists the <base> tag attributes.
| Attribute | Accepted Values | Description |
|---|---|---|
| href | URL | Base URL for all relative page URLs |
| id | identifier | Defines a unique identifier for the base. |
| target |
_blank _self _parent _top framename |
Defines where or how to open the linked pages |
For additional global attributes see our global attributes list.
The <base> tag is part of a group of tags that
define the structure of a web page.
This group is referred to as the Page tag group.
Together, they allow you to create solid, well-structured web pages.
Here is the complete list.
| Element | Description |
|---|---|
| <!DOCTYPE> | Must appear on the first line of a page. Specifies the HTML version |
| <html> | Defines the root container for an HTML document |
| <head> | Creates a head container that holds page-level metadata elements |
| <meta> | Provides metadata about a web page |
| <link> | Defines a link to an external source, such as a style sheet |
| <base> | Sets the base URL for all relative URLs on a page |
| <script> | Adds JavaScript to a page. Either client- or server-side |
| <style> | Adds CSS style elements to a page |
| <title> | Specifies the page title that displays in the browser's tab |
| <body> | Specifies a container for the content of the page, with text, links, images, etc. |
Here is when <base> support started for each browser:
![]() Chrome
|
1.0 | Sep 2008 |
![]() Firefox
|
1.0 | Sep 2002 |
![]() IE/Edge
|
1.0 | Aug 1995 |
![]() Opera
|
1.0 | Jan 2006 |
![]() Safari
|
1.0 | Jan 2003 |