HTML base tag

HTML <base> Tag: The HTML base tag describes the base URL for all the relative URLs in a document. There must be only one base element and it should be inside the <head> element. And this tag belongs to the Metadata Content category. This URL will be the base URL for every link on the page and will be prefixed before each of them.

HTML <base> Tag

The <base> tag supports Global attributes but doesn’t support event attribute. The base tag must be defined between the head tags. And there can be a maximum of only 1 base tag in a page.

Syntax: <base href=” ” target=” “>

Browser compatibility

The <base> tag is supported by  different browsers.

  • Chrome
  • Firefox
  • Safari
  • InternetExplorer
  • Opera

Example:

<!DOCTYPE html>
<html>
<head>
  <base href="https://freshersnow.com" target="_blank">
</head>
<body>
<p><img src="https://tutorials.freshersnow.com/wp-content/uploads/2019/04/HTML-Tutorial.jpg" width="250" height="250" alt="Freshersnow"> <br>Freshersnow Tutorials</p>
</body>
</html>

Output:

HTML base tag

 

 

Attributes supported by the <base> tag

Attribute Value Description
href URL Specifies the base URL for all relative URLs in the page
target _blank
_parent
_self
_top
frame name
Specifies the default target for all hyperlinks and forms in the page