- Element of
- HTML Anchors & Links: The Right Way to Use them In Your HTML Code
- What does
<base> HTML Tagdo?
- The <base> element is used to identify a base URL upon which to build all relative URLs that appear on a webpage. In addition, if the <base> element has a target attribute, the target attribute will be used as the default attribute for all hyperlinks appearing in the document.
- Null element
- This element must not contain any content, and does not need a closing tag.
<head> . . . <base href="http://example.com" target="_blank"> </head>
With relative URLs a slash (
/ ) indicates the root URL of the current page, so
href="/page-name" would link to a page at currentdomain
/page-name. Leaving off the slash links to a subpage of the current URL, so
href="page-name" would link to current_url
<base> element, you can change the base URL which the relative links on the page use. Instead of the current, actual URL of the current page, all relative links will be based on the URL specified in the
href attribute of the
For more information about how relative links work, see our documentation on anchor link urls.
In addition to specifying a base URL for relative links, the
<base> element allows you to specify a default
target value for all links on the page. So, if you set
target="_blank" in the
<base> element, all links on the page (relative and absolute) will open in a new window, unless otherwise specified.
Placement and restrictions
<base> element must be placed within the document's
<head>, and there must only be one
<base> element in a document. The
<base> element must not have any content, and does not require a closing tag.
Browser Support for base