The HTML5 Specification introduces many new semantic elements, as well as specifications for existing elements; one of which is the
<base> Tag, which allows for specifying a root URL from which all linkable elements in a document (hyperlinks, images etc.) are based, as well as a default
target for all linkable elements.
<base>Tag provides two attributes;
href(Hyper-text Reference) and
target, respectively, which have the same semantic meaning as that of a
- Only a single
<base>Tag is to be defined per page and, must be defined before any elements which except a
URLare defined (other than the
Like all HTML markup, usage of the
<base> Tag is easy and straightforward: Simply add a single
<base> Tag in the
<head> element of the document and define either a base URL and / or default target attribute.
Defining a default base URL and target:
<base href="http://somedomain/app" target="_blank" />
<a href="aboutus.php">About Us</a>
<a href="contactus.php">Contact Us</a>
The above links will all default to a blank
target (new page), with each link’s base URL defaulting to “http://somedomain/app”. Individual links can override the base URL as well as the default
<base> Tag is currently supported by all major browsers.