HTML <base> tag

HTML <base> tag : Definition

• HTML <base> tag is used to specify a base URI or URL to use for all relative links on a document.

== Important Note ==

• The <base> tag must have either an href or a target attribute present, or both.

• There can only be one single <base> element in a document, and it must be inside the <head> element.



<base> tag example :


  <!DOCTYPE html>
<html>
   <head>
      <title>HTML base Tag example</title>
      <base href = "https://www.aimtocode.com" />
   </head>

   <body>
      HTML: <img src = "app-assets/images/course-images/html-tutorial.png"/>
   </body>
</html>

Output:


   HTML: 


Global Attributes

The <base> tag supports all the global attributes.

Specific Attributes

The HTML <base> tag also supports the following additional attributes −

Attribute Value Description
href URL Specifies the URL of a page or the name of the anchor that the link goes to.
target _blank
_parent
_self
_top

Where to open the target URL.

_blank − the target URL will open in a new window.

_self − the target URL will open in the same frame as it was clicked.

_parent − the target URL will open in the parent frameset

_top − the target URL will open in the full body of the window



Event Attributes

The <base> tag does not support any event attributes in HTML.