Definition
The <base> Tag specifies the base URL for all relative URLs used in your web page.
Example
<head>
<base href="https://www.thewebmaster.com/" target="_blank">
</head>
<body>
<a href="/seo/">View SEO articles</a>.
</body>Usage
There can only be one
<base>element in a document. If multiple are used, only the firsthrefandtargetattributes are used.The
<base>element must be contained in the<head>. It must come before any other elements with attribute values of URLs, such as the<link>element’shrefattribute.The
<base>element does not have a closing tag.In-page anchors use the
<base>. If you wish to link to something on the same page, you will also need to specify the directory in thehrefattribute.For example:
<head> <base href="https://www.thewebmaster.com/" target="_blank"> </head> <body> <p><a href="#best-practices">View best practices</a> links to https://www.thewebmaster.com/#best-practices.</p> <p><a href="develop/reference/html/tags/base/#best-practices">View best practices</a> links to https://www.thewebmaster.com/html/tags/base/#best-practices.</p> </body>Open Graph tags do not use
<base>.
Attributes
The Base element supports the Global Attributes, as well as the following:
hrefThe
hrefattribute specifies the base URL of the page used for all relative links.<a href="https://www.thewebmaster.com" >Visit The Webmaster</a>targetThe
targetattribute when used with the<base>element specifies the default way to open<a>,<area>, or<form>elements. You can override it by specifying a<target>attribute on any of those elements.Values can include:
- _blank
- _parent
- _self
- _top
Specification
Browser Support
Desktop
| Chrome | Edge | Firefox | IE | Opera | Safari |
|---|---|---|---|---|---|
| Yes | Yes | Yes | Yes | Yes | Yes |
Mobile
| Android Webview | Chrome Android | Firefox Android | Opera Android | iOS Safari | Samsung Internet |
|---|---|---|---|---|---|
| Yes | Yes | Yes | Yes | Yes | Yes |
