HTML <base> Tag

The <base> tag defines the base for all relative URLs. Its purpose is to simplify and shorten relative links on the page. A page should have only one <base> tag.




A <base> element.
All relative URLs in the page start with

<base href="">

Using <base>

The <base> tag is used to set the base URL for all relative URLs on a page.

Its main purpose is to simplify and shorten the relative links on the page.

There can be only one <base> tag on a page and it must be inside the <head> tag.

Note: The <base> element must be placed before any element with a URL reference, such as <link>.

More Examples

A <base> tag that makes all relative links use the base URL
Notice how it shortens the relative URLs in the HTML.

  <base href="">

  <a href="Vincent_van_Gogh">Vincent Van Gogh</a> <br />
  <a href="Henri_Matisse">Henri Matisse</a> <br />
  <a href="Paul_Cézanne">Paul Cézanne</a>

Note: The <base> element also shortens the URLs on the src attribute used in image, audio, video, and others.

Attributes for <base>

This table lists the <base> tag attributes.

Attribute Accepted Values Description
href URL Base URL for all relative page URLs
id    identifier Defines a unique identifier for the base.
target _blank
Defines where or how to open the linked pages

For additional global attributes see our global attributes list.

Page Tags

The <base> tag is part of a group of tags that define the structure of a web page. This group is referred to as the Page tag group. Together, these tags allow you to create solid, well-structured web pages.

Here is the complete list.

Element Description
<!DOCTYPE> Must appear on the first line of a page. Specifies the HTML version
<html> Defines the root container for an HTML document
<head> Creates a head container that holds page-level metadata elements
<meta> Provides metadata about a web page
<link> Defines a link to an external source, such as a style sheet
<base> Sets the base URL for all relative URLs on a page
<script> Adds JavaScript to a page. Either client- or server-side
<style> Adds CSS style elements to a page
<title> Specifies the page title that displays in the browser's tab
<body> Specifies a container for the content of the page, with text, links, images, etc.

Browser support

Here is when <base> support started for each browser:

1.0 Sep 2008
1.0 Sep 2002
1.0 Aug 1995
1.0 Jan 2006
1.0 Jan 2003

You may also like