html tutorial - Base <base> tag in HTML - html5 - html code - html form



base tag

Learn html - html tutorial - base tag - html examples - html programs

  • <base> element is used for the base URL for all relative documents in the HTML page.
  • Only one base element is used inside the <head> element in HTML document.
  • <base> tag supports Global attributes.
  • <base> tag belongs to Metadata Content category.

Syntax for <base> tag:

<base>Content here...</base>

Sample Coding for <base> tag:

Tryit<!DOCTYPE html>
<html >
    <head>
        <base target="_blank" href="http://www.wikitechy.com/">
    </head>
    <body>
        <p>
            Here "http://www.wikitechy.com/" is a base URL.
            Click below to go Wikitechy tutorials.    
        </p> 
        <p><a href="online-tutorials">Wikitechy online tutorials</a>-<br>
            Wikitechy online tutorials page is open from the base URL.</p>
    </body>
</html>

Code Explanation for <base> tag in HTML:

code explanation for <base> tag

  1. In the <base> tag “href=http://www.wikitechy.com/” is base URL for all the related URLs in the documents.
  2. <a href="online-tutorials"> this will be navigate to “http://www.wikitechy.com/online-tutorials”. If we cannot set the tag URL that will be navigate to the “online-tutorials” document in the current directory.
  3. Note: <base> tag is declare within the head element only.

Output of <base> tag:

output for <base> tag

  1. If user click the “Wikitechy online tutorials” link that will be redirected to Wikitechy online tutorials page in wikitechy.com website.

Attributes of <base> tag in HTML:

Attribute Value HTML4 HTML5 Description
href URL Yes Yes Denotes the base URL for all relative URLs in the page
target _blank
_parent
_self
_top
framename
Yes Yes Denotes the default target for all hyperlinks and forms in the page

Browser Support for <base> tag:

Yes Yes Yes Yes Yes

Tips and Notes

  • The <base> tag is the first element inside the <head> element, so that other elements inside the head section uses the information from the <base> element.
  • The <base> tag is present, it must have href or a target attribute, or both.

Related Searches to meta tag in html