The <BASE> tag has been a part of HTML for decades now, and little has changed with the tag itself as we’ve transition to 2018. At its core, the <BASE> tag creates a document base – off which relative hyperlinks in the body of the document will go.
Change The Base URL For All Links On A Page
By default, all relative links on a website will act off the domain on which they are called. For example, if I added relative link to /contact from this page – the base would be https://rapidpurple.com.
<head> </head> <a href="/contact">/contact</a>
However if I were to define the base tag with an HREF attribute set to https://mediaexplode.com, watch what happens to the same link:
<head> <base href="https://mediaexplode.com/"> </head> <a href="/contact">/contact</a>
Changing The Target For All Links On A Page
The <BASE> tag has another great purpose – it can be used to easily set all links on a page to open in a new window, or a specific frame. This can be accomplished using the second attribute supported by <BASE>, the target attribute.
For example, if we wanted to make all links open in a new window, we could set our target attribute to _blank, just like we would for a regular link.
<head> <base target="_blank"> </head>
Just keep in mind that there can be only be one defined <BASE> within a document, and it must be inside the <HEAD> element.