HTML <base> Base Tag
Tags: learnhtml
Published: 2021-02-13 09:43:47

---
title: HTML <base> Base Tag
published: true
date: 2021-02-12 06:29:07 UTC
tags: LearnHTML
canonical_url: https://sharepointanchor.com/learn-html/html-base-tag/
---

In HTML, the <base> Base tag is used to **specify a (absolute) base URL or URI** for all the relative links. This tag also determines how the link in the current document should be opened.

If you specified any URL with <base> tag, then every other URL on the page prefixed with the specified base URL. The base tag must be defined between the **<head>** tag.

Note: In HTML the base tag **must be included only once** in the document, and it must be placed in the **<head>** element.

You can access the used base URL of a document from scripts with a **document.baseURI**. Suppose the document doesn’t contain any <base> element, base URL will default to **document.location.href**.

<svg aria-hidden="true" focusable="false" data-icon="clock" width="20" height="20" fill="none" stroke="currentColor" style="display:inline-block;vertical-align:-0.1em" role="img" xmlns="http://www.w3.org/2000/svg" viewbox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"></path></svg>Estimated reading time: 2 minutes

## Syntax:

The <base> tag contains **only the open tag** in **HTML** , it does not have the closing tag. But in **XHTML** the <base> tag must be **closed with <base/> tag**. Do not add any content inside the HTML <base> tag.

```

<base href="SAMPLE URL">

```

Note: If you use **multiple <base> elements** on a page, it will **consider the first href and target attribute**. Other URLs will be ignored.

## Sample of HTML <base> Tag:

```

<!DOCTYPE html>
<html>
  <head>
    <title>HTML base tag</title>
    <base href="https://www.sharepointanchor.com/" target="_blank">
  </head>
  <body>
<p>HTML</p>
    <img src="https://sharepointanchor.com/wp-content/uploads/2021/02/html.png" alt="" class="wp-image-500"/>
  </body>
</html>

```

## Result:

![](https://sharepointanchor.com/wp-content/uploads/2021/02/result-9.png)

<script async src="//jsfiddle.net/Share_Point_Anchor/506xv4e9/7/embed/html,result/"></script>

## Attributes:

The **<base>** tag supports the **global attributes** and the **event attributes**. You can use the following properties to style an [HTML](https://sharepointanchor.com/category/learn-html/) base tag.

<style> th, td{ padding: 20px; } </style>

| Attribute | Value | Definition |
| --- | --- | --- |
| href | URL | This attribute **specifies the base URL for all relative URLs of the page**. The default base address is substituted before all relative addresses on the page. |
| target | \_blank | It helps to **open the link in a new window**. |
| \_self | It is a default. Helps to open the link in the **current window**. |
| \_parent | This attribute value opens the link in the **parent frame**. |
| \_top | It will open the document in the **full width of the page**. |

## Browser Support:

![](https://sharepointanchor.com/wp-content/uploads/2021/02/Browser-Support-5.png)<figcaption>Browser Support</figcaption>

### Read Also:

- **[HTML <a> Anchor Tag](https://sharepointanchor.com/learn-html/html-anchor-tag/)**
- **[HTML <aside> Aside Tag](https://sharepointanchor.com/learn-html/html-aside-tag/)**
- **[HTML <applet> Applet Tag](https://sharepointanchor.com/learn-html/html-applet-tag/)**
- **[HTML <area> Area Tag](https://sharepointanchor.com/learn-html/html-area-tag/)**

The post [HTML <code><base></code> Base Tag](https://sharepointanchor.com/learn-html/html-base-tag/) appeared first on [Share Point Anchor](https://sharepointanchor.com).