Dofactory.com
Dofactory.com

HTML <base> href Attribute

An href on a <base> tag defines the base URL for all relative links on a page.

This value affects all relative URLs on the page.

Example

#

A <base> element with an href attribute.
With this setting all relative links on the page start from https://en.wikipedia.org/wiki/.

<head>
  <base href="https://en.wikipedia.org/wiki/">
</head>

<nav>
  <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>
</nav>

Using href

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

This attibute affects URLs on <a>, <link>, <img>, <video>, <audio>, and other elements.


Syntax

<base href="URL" />

Values

#

Value Description
URL URL to be used as the prefix of all relative URLs in the page.

Browser support

Here is when href support started for each browser:

Chrome
1.0 Sep 2008
Firefox
1.0 Sep 2002
IE/Edge
1.0 Aug 1995
Opera
1.0 Jan 2006
Safari
1.0 Jan 2003

You may also like

 Back to <base>

Author: Jack Poorte
Published: Jun 20 2021
Last Reviewed: Sep 30 2023


What's your favorite/least favorite part of Dofactory?


Guides