HTML Tags
Advertisements

HTML <base> Tag

Topic: HTML5 Tags ReferencePrev|Next

Description

The <base> tag defines the base URL and a common target to for all relative URLs contained within a document. There must be no more than one <base> tag per document.

The following table summarizes the usages context and the version history of this tag.

Parent: <head>
Content: None. It is an empty element.
Start/End Tag: Start tag: required, End tag: forbidden
Version: HTML 2, 3.2, 4, 4.01, 5

Syntax

The basic syntax of the <base> tag is given with:

HTML:<base href="URL">; XHTML:<base href="URL" />

The example below shows the <base> tag in action.

<!DOCTYPE html>
<html lang="en">
<head>
    <title>Example of HTML base tag</title>
    <base href="https://www.tutorialrepublic.com/">
</head>
<body>
    <p>Learn <a href="css-tutorial/">CSS</a>.</p>
</body>
</html>

The relative URL "css-tutorial/" would resolve to:

https://www.tutorialrepublic.com/css-tutorial/

Note: If multiple <base> tags are specified, only the first 'href' and first 'target' attribute's value are used, all others are ignored.


Tag-Specific Attributes

The following table shows the attributes that are specific to the <base> tag.

Attribute Value Description
Required — One of the following attributes must be specified for the markup to be valid.
href URL Specifies the base URL for all relative URLs in the document.
target _blank
_parent
_self
_top
Specifies the default location to display the result when hyperlinks or forms in the document cause navigation.

Global Attributes

Like all other HTML tags, the <base> tag supports the global attributes in HTML5.


Event Attributes

The <base> tag also supports the event attributes in HTML5.


Browser Compatibility

The <base> tag is supported in all major modern browsers.

Browsers Icon

Basic Support—

  • Firefox 1+
  • Google Chrome 1+
  • Internet Explorer 2+
  • Apple Safari 1+
  • Opera 4+

Further Reading

See tutorial on: HTML Links.

Related tag: <a>.

Advertisements
Bootstrap UI Design Templates Property Marvels - A Leading Real Estate Portal for Premium Properties