HTML Tags – Base Tag


What is HTML <base> tag ?

HTML <base> tag is used to specify the base URL and/or target URL, for relative links.

HTML <base> tag must have either an href or a target attribute present in it or both.

There can be only one <base> element in a document.

HTML <base> tag must be defined inside the <head> element.


Why HTML <base> tag is used ?

If there is multiple links in the webpage but the base url is same we can use <base> tag.

How HTML <base> tag works ?

We can define the <base> tag URL and other relative links will use the <base> URL as the starting point.

For example, If we set the base URL once in the header section, then all subsequent relative links will use that URL as a starting point.

HTML coding for a website !!!

Click to Learn More about – HTML Tutorial for beginners

Syntax :

<base href="www.example.com" target="_blank">

Example :

<DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<base href="https://s30.e0b.myftpupload.com/" target="_blank">
</head>
<body>
<p>Learn about <a href="client-side-html">HTML Tutorials</a></p>
<p>Learn about <a href="server-side">Java Tutorials</a></p>
</body>
</html>

<base> Tag Attributes

HTML <base> tag support following specific attributes.

SnoAttributesValueDescription
1hrefurlDefine a base URL link.
2target_blank
_parent
_self
_top
Loads the linked document in new window.
Loads the linked document in the parent frame.
Loads the linked document in the same window.
Loads the linked document in the top up on same window.

Browser Compatibility

SnoBrowserSupport
1ChromeYes
2FirefoxYes
3EdgeYes
4OperaYes
5SafariYes
6Internet ExplorerYes