Loading...
HTML <base> Tag

HTML <base> Tag

In this tutorial, we will learn about base tag in HTML with the help of examples.


<base> Tag

Base tag <base> is used to specifies the base URL for all relative URL in a document.
A base URL is the consistent part of your web address i.e. every URL follows the base URL.
We can use only one base tag in an HTML document inside the head tag only.

<base> tag is declared inside <head> tag.

Note : The base tag must have an href attribute present in it.

Syntax

<base>....</base>

Example

<!DOCTYPE html>
<html>
  <head>
    <title>Base Tag</title>
    <base href = "www.google.com" target = "_blank">
  </head>
  <body>
    <a>It's harder to read code than to write it.</a>
  </body>
</html>

Output

It's harder to read code than to write it.

Specific Attribute

Attribute Value Description
href URL Specifies the URL of a page or the name of the anchor we want to hyperlink the document
target _blank
_parent
_self
_top
Specifies 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

Global Attribute

Base Tag support all the global attributes of HTML.


Event Attribute

Base Tag support all the event attributes of HTML.


Next Tutorial

We hope that this tutorial helped you develop better understanding of the concept of Base tag in HTML.

Keep Learning : )

In the next tutorial, you'll learn about HTML bdi Tag.

- Related Topics