Horje
What is HTML <base> Tag | HTML Tag Code
What is HTML <base> Tag

HTML <base> Tag Specifies the base URL/target for all relative URLs in a document.

The <base> tag specifies the base URL and/or target for all relative URLs in a document.

The <base> tag must have either an href or a target attribute present, or both.

There can only be one single <base> element in a document, and it must be inside the <head> element.


How to use HTML <base> Tag

Specify a default URL and a default target for all links on a page:
index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
  <base href="https://horje.com/learn/634/what-is-html-b-tag" target="_blank">
</head>

Output should be:

How to use HTML <base> Tag

What Audio Format and Browser will Support for HTML <base> Tag

Output should be:

What Audio Format and Browser will Support for HTML <base> Tag

Attributes for HTML <base> Tag

Attribute Value Description
href URL Specifies the base URL for all relative URLs in the page
target _blank
_parent
_self
_top
Specifies the default target for all hyperlinks and

How to add HTML <base> href Attribute

Specify a base URL for all relative URLs on a page.

Definition and Usage

The href attribute specifies the base URL for all relative URLs on a page.

Syntax

<base href="URL">

Attribute Values

Value Description
URL An absolute URL that acts as the base URL (like "http://www.example.com/")
index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
  <base href="https://horje.com">
</head>
<body>

<h1>The base href attribute</h1>

<p><img src="https://horje.com/avatar.png" width="24" height="39" alt="Stickman"> - Notice that we have only specified a relative address for the image. Since we have specified a base URL in the head section, the browser will look for the image at "https://horje.com/avatar.png".</p>

</body>
</html>

Output should be:

How to add HTML <base> href Attribute

How to add HTML <base> target Attribute

Specify a default target for all hyperlinks and forms on a page.

Definition and Usage

The target attribute specifies the default target for all hyperlinks and forms in the page.

This attribute can be overridden by using the target attribute for each hyperlink/form.

Browser Support

Syntax

<base target="_blank|_self|_parent|_top">

Attribute Values

Value Description
_blank Opens the link in a new window or tab
_self Default. Opens the link in the same frame as it was clicked
_parent Opens the link in the parent frame
_top Opens the link in the full body of the window
index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
  <base target="_blank">
</head>
<body>

<h1>The base target attribute</h1>

<p><a href="https://horje.com">Horje.com</a> - Notice that the link opens in a new window, even if it has no target="_blank" attribute. This is because the target attribute of the base element is set to "_blank".</p>

</body>
</html>

Output should be:

How to add HTML <base> target Attribute

How to add HTML <base> target _blank Attribute

_blank Opens the link in a new window or tab
index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
  <base target="_blank">
</head>
<body>

<h1>The base target attribute</h1>

<p><a href="https://horje.com">Horje.com</a> - Notice that the link opens in a new window, even if it has no target="_blank" attribute. This is because the target attribute of the base element is set to "_blank".</p>

</body>
</html>

Output should be:

How to add HTML <base> target _blank Attribute

How to add HTML <base> target _self Attribute

_self Default. Opens the link in the same frame as it was clicked
index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
  <base target="_self">
</head>
<body>

<h1>The base target attribute</h1>

<p><a href="https://horje.com">Horje.com</a> - Notice that the link opens in a new window, even if it has no target="_blank" attribute. This is because the target attribute of the base element is set to "_self".</p>

</body>
</html>

Output should be:

How to add HTML <base> target _self Attribute

How to add HTML <base> target _parent Attribute

_parent Opens the link in the parent frame
index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
  <base target="_parent">
</head>
<body>

<h1>The base target attribute</h1>

<p><a href="https://horje.com">Horje.com</a> - Notice that the link opens in a new window, even if it has no target="_blank" attribute. This is because the target attribute of the base element is set to "_parent".</p>

</body>
</html>

Output should be:

How to add HTML <base> target _parent Attribute

How to add HTML <base> target _top Attribute

_top Opens the link in the full body of the window
index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
  <base target="_top">
</head>
<body>

<h1>The base target attribute</h1>

<p><a href="https://horje.com">Horje.com</a> - Notice that the link opens in a new window, even if it has no target="_blank" attribute. This is because the target attribute of the base element is set to "_top".</p>

</body>
</html>

Output should be:

How to add HTML <base> target _top Attribute



Read Full::
HTML Tag Code
Category:
HTML Code
Sub Category:
HTML Tag Code
Uploaded:
4 months ago
Uploaded by:
Admin
Views:
1

Related Articles
What is HTML <!--...--> Tag HTML Tag Code
What is HTML <!DOCTYPE> Declaration HTML Tag Code
What is HTML Elements and Doctypes HTML Tag Code
What is HTML <a> Tag HTML Tag Code
What is HTML <abbr> Tag HTML Tag Code
What is HTML <address> Tag HTML Tag Code
What is HTML <applet> Tag HTML Tag Code
What is HTML <area> Tag HTML Tag Code
What is HTML <article> Tag HTML Tag Code
What is HTML <aside> Tag HTML Tag Code
What is HTML <audio> Tag HTML Tag Code
What is HTML <b> Tag HTML Tag Code
What is HTML <base> Tag HTML Tag Code
What is HTML <basefont> Tag HTML Tag Code
What is HTML <bdi> Tag HTML Tag Code
What is HTML <bdo> Tag HTML Tag Code
What is HTML <big> Tag HTML Tag Code
What is HTML <blockquote> Tag HTML Tag Code
What is HTML <body> Tag HTML Tag Code
What is HTML <br> Tag HTML Tag Code
What is HTML <button> Tag HTML Tag Code
What is HTML <canvas> Tag HTML Tag Code
What is HTML <caption> Tag HTML Tag Code
What is HTML <center> Tag HTML Tag Code
What is HTML <cite> Tag HTML Tag Code
What is HTML <code> Tag HTML Tag Code
What is HTML <col> Tag HTML Tag Code
How to create HTML <colgroup> Tag HTML Tag Code
What is HTML <data> Tag HTML Tag Code
What is HTML <datalist> Tag HTML Tag Code
What is HTML <dd> Tag HTML Tag Code
What is HTML <del> Tag HTML Tag Code
What is HTML <details> Tag HTML Tag Code
What is HTML <dfn> Tag HTML Tag Code
What is HTML <dialog> Tag HTML Tag Code
What is HTML <dir> Tag HTML Tag Code
What is HTML <div> Tag HTML Tag Code
What is HTML <dl> Tag HTML Tag Code
What is HTML <dt> Tag HTML Tag Code
What is HTML <em> Tag HTML Tag Code
What is HTML <embed> Tag HTML Tag Code
What is HTML <fieldset> Tag HTML Tag Code
What is HTML <figcaption> Tag HTML Tag Code
What is HTML <figure> Tag HTML Tag Code
What is HTML <font> Tag HTML Tag Code
What is HTML <footer> Tag HTML Tag Code
What is HTML <form> Tag HTML Tag Code
What is HTML <frame> Tag HTML Tag Code
What is HTML <frameset> Tag HTML Tag Code
What is HTML <h1> to <h6> Tags HTML Tag Code
What is HTML <head> Tag HTML Tag Code
What is HTML <header> Tag HTML Tag Code
What is HTML <hgroup> Tag HTML Tag Code
What is HTML <hr> Tag HTML Tag Code
What is HTML <html> Tag HTML Tag Code
What is HTML <i> Tag HTML Tag Code
What is HTML <iframe> Tag HTML Tag Code
What is HTML <img> Tag HTML Tag Code
What is HTML <input> Tag HTML Tag Code
What is HTML <ins> Tag HTML Tag Code
What is HTML <kbd> Tag HTML Tag Code
What is HTML <label> Tag HTML Tag Code
What is HTML <legend> Tag HTML Tag Code
What is HTML <li> Tag HTML Tag Code
What is HTML <link> Tag HTML Tag Code

Single Articles
How to use HTML <base> Tag
What Audio Format and Browser will Support for HTML <base> Tag
Attributes for HTML <base> Tag
How to add HTML <base> href Attribute
How to add HTML <base> target Attribute
How to add HTML <base> target _blank Attribute
How to add HTML <base> target _self Attribute
How to add HTML <base> target _parent Attribute
How to add HTML <base> target _top Attribute

Share on: