<base> tag

HTML <base> tag

The <base>  tag sets the base URL for all the relative URLs.

This acts as a default URL which will be common default target URL for all other relative URLs.

Syntax for HTML4/HTML5:
<base href=”URL_path” >

Syntax for XHTML:
<base href=”URL_path”  />

 

Note/Info:
There can be only 1 base url for each HTML document hence, ideally there should be only one <base>  tag for each HTML document.

If there are more than 1 base URLs in the document, then the first <base>  element will be used.

Example

<!DOCTYPE html>
<html>
  <head>
    <title>Page Title</title>
    <base href="https://www.tutorialbrain.com" target="_self">
  </head>
  <body>
    <p> Eat yummy cake and master HTML Tags:</p>
    <img src="editor_html/cake.jpg">
    <p><a href="html_tutorial/html_tags/">HTML Tags</a></p>
  </body>
</html>

Default CSS Value

NONE

Difference between HTML4.01, XHTML and HTML5

HTML4 XHTML HTML5
Does not have an End tag Must use an End tag Does not have an End tag

Attributes used with <base> tag

Attribute Description
href You need to set the base URL here.
target To define the destination tab or window where the target URL will be open.It can take the followging values -
  • _blank
  • _self
  • _top
  • _parent

  • You can also code a name of the frame to open the target URL in that frame i.e. target="name_of_frame".

    Global Attributes

    The <base> tag supports Global attributes.

    Event Attributes

    The <base> tag supports Event attributes.

    Supporting Browsers

    supporting-browsers for tags

    Related Tags

    <a> tag.

    Tutorials for all brains!