BASE (<base>) Tag

by Jai 28-May-19

0 456


The <base> Tag is used to identify a base URL that targets for all relative URLs in a document. Basically, the <base> tag is always written inside head Tag.

The <base> tag contain two important attributes i.e. href and Target in which href is mandatory whereas the target attribute is an optional. This base tag work for relative URL.

For Example:
When we are creating an anchor link, the href attribute is used to specify an absolute URL (base URL), like http://codingtag.com or a relative URL such as https://www.codingtag.com/html-meta-tags ( /, /page-name). Relative URL may have /, /page-name.

Browsers Support:

Google Chrome
Firefox
Safari
Internet Explorer

BASE (<base>) Tag

BASE (<base>) Tag

BASE (<base>) Tag

BASE (<base>) Tag

Code:

<!DOCTYPE html>
<html>
<head>
<title> HTML base Tag </title>
<base href="https://www.codingtag.com" target="_blank">
</head>
<body>
<h2> HTML Base Tag </h2>
<p> <a href="/html-meta-tags"> Coding Tag </a>
<br>
You notice that when click on this above link(Coding Tag) it is open in new window tab <br>
even it has no any target (target="_blank") attribute.
<br>it happen because of target attribute of the base element is set to "_blank".
<p>
</body>
</html>

Output:

BASE (<base>) Tag


Share:


Comments

    Waiting for your comments

Leave a Reply