Code has been added to clipboard!

HTML base Tag

Reading time 2 min
Published Mar 19, 2019
Updated Oct 1, 2019

HTML base Tag: Main Tips

  • <base> element defines base URL for all the relative links in the HTML document.
  • HTML <base> tag does not have the closing tag.

Use of base

<base> specifies the HTML base URL for relative links in a web page.

Example
<head>
  <title>HTML base tag example</title>
  <base href="https://www.bitdegree.org/courses">
</head>

There are certain rules for using this element:

  • <base> HTML must be included only once in the HTML file.
  • It has to be put in the <head>.
  • Do not add content inside the HTML <base> tag.
  • Do not include a closing tag.

Attributes for base

href

The <base href=""> defines the base URL for all the relative URLs in the document.

Example
<head>
  <base href="https://www.bitdegree.org/course/">
</head>

target

By including the target attribute, you can set the <base> HTML to open links either in the current browser window or in a new one.

Example
<head>
<base target="_blank">
</head>
  • _self opens the link in the same browser window.
  • _blank opens the link in a new browser window.
  • _parent opens a link in a parent window of the current window.
  • _top opens a link in the top-level browsing window.

Browser Support

Chrome
All
Edge
All
Firefox
1+
IE
All
Opera
All
Safari
All

Mobile Browser Support

Chrome
All
Firefox
4+
Opera
All
Safari
All
Basics
Introduction
Syntax
Editors
Basic Examples
Head Section
<!DOCTYPE>
Tags and Elements
Semantic Elements
Tags Reference
Attributes
Comments
Block and Inline Elements
Forms
Form Elements
Input
Responsive Web Design
Inline Scripts
Uniform Resource Locator
Redirect
XHTML
Geolocation
Drag and Drop
Local Storage
Web Workers
Server-Sent Events
Character Encoding
Text Formatting
Quotation and Citation Elements
Headings
Paragraphs
Links
Tables
Lists
Symbols
Space
Tab
Styles
Computer Code
Layout
Classes
Colors
Images
iframes
Audio Player
Video Player
YouTube Videos
Multimedia
Canvas
SVG
<!-- -->
<a>
<abbr>
<acronym> DEPRECATED
<address>
<applet> DEPRECATED
<article>
<aside>
<audio>
<b>
<base>
<basefont> DEPRECATED
<bdi>
<bdo>
<big> DEPRECATED
<blink> DEPRECATED
<blockquote>
<body>
<br>
<button>
<canvas>
<caption>
<center> DEPRECATED
<cite>
<code>
<col>
<colgroup>
<datalist>
<dd>
<del>
<details>
<dfn>
<dialog>
<dir> DEPRECATED
<div>
<dl>
<dt>
<em>
<embed>
<fieldset>
<figcaption>
<figure>
<font> DEPRECATED
<footer>
<form>
<frame> DEPRECATED
<frameset> DEPRECATED
<h1> – <h6>
<head>
<header>
<hr>
<html>
<i>
<iframe>
<img>
<input>
<ins>
<kbd>
<keygen> DEPRECATED
<label>
<legend>
<li>
<link>
<main>
<map>
<mark>
<menu>
<menuitem> DEPRECATED
<meta>
<meter>
<nav>
<noframes> DEPRECATED
<noscript>
<object>
<ol>
<optgroup>
<option>
<output>
<p>
<param>
<pre>
<progress>
<q>
<rp>
<rt>
<ruby>
<s>
<samp>
<script>
<section>
<select>
<small>
<source>
<span>
<strike> DEPRECATED
<strong>
<style>
<sub>
<summary>
<sup>
<table>
<tbody>
<td>
<tfoot>
<th>
<thead>
<time>
<title>
<tr>
<track>
<tt> DEPRECATED
<u>
<ul>
<var>
<video>
<wbr>