HTML base tag

Html <base> tag specifies the alternate or default URL (address) for all the hyperlinks present in a page. This default URL is written in the href attribute of the <base> element.


<!DOCTYPE html>
 <base href="" target="_blank">
 <p>We have not given any address but the default address is in the href     attribute of base tag.</p>
 <a href="">Browser</a><br>
 <a href="">Search</a>
Try </>

Only one element should be used only once in a page.

If there are more than one base elements then all the base elements are ignored except the first one.

If there are more than elements with different target attributes then all are ignored except first one.

Tag omission

the base is self-closing element (</base>) i.e. there is no end tag.

Global Attributes

All global attributes are applicable on the base element.

Specific Attributes

href attribute

The value of this attribute is a valid URL. There are four different values for the href attribute.

<base> tag attributes

href href attribute defines the location of the external resource.
<base href="URL" target="_blank">

target attribute

There are four browsing modes.


The default value of the target is '_self'. It means the link opens in the current window.

<base href="" target="_self" />


This attribute opens the linked source in new window.

<base href="" target="_blank" />


It opens the linked source in the parent block(window) of the current block or window.

<base href="" target="_parent" />

if the parent is not present then link opens in current window.


If the link is present in nested frames then the link opens in the top most browsing context (frame).

<base href="" target="_parent" />

If there is no top target frame, then link opens in the same window(frame).

Visit target attribute for more information.

Was this article helpful?




Get the newsletter