English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

HTML Reference Manual

HTML Tag Directory

HTML: <base> href attribute

<base> tag specifies the base URL for all relative URLs in the document /A document can contain at most one <base> element, and this element must be within the <head> element.

 HTML <base> tag

Online Example

Specify the default URL and default target for all links on the page:

<!DOCTYPE html>
<html>
<head>
<title>HTML:<base> href attribute - 基础教程网 oldtoolbag.com</title>
<base href="https://www.oldtoolbag.com/" target="_blank">
</head>
<body>
<p>Please note that we only specify relative addresses for images. Since we have specified the base URL in the header, the browser will use "https://www.oldtoolbag.com/static/images/locating the image</p>
<img src="static/images/colormap.gif" width="234" height="199" alt="colormap">
<a href="tags/tag-base.html">HTML base Tag</a>
</body>
</body>
</html>
Test to see ‹/›

Browser Compatibility

IEFirefoxOperaChromeSafari

All major browsers support the href attribute.

Definition and Usage

The <base> tag specifies the base URL for all relative URLs in the document /Target.
A document can contain at most one <base> element, and it must be within the <head> element.

Note: If the <base> tag is present, it must have the href attribute or the target attribute, or both.

HTML 4.01and HTML5Differences

None.

Differences between HTML and XHTML

In HTML, the <base> tag has no closing tag.
In XHTML, the <base> tag must be properly closed.

Event Attributes

None. The <base> tag does not support any event attributes.

Syntax

<base href="URL">

Attribute Value

ValueDescription
URLas an absolute URL for the base URL (e.g. "https://www.oldtoolbag.com/)。

 HTML <base> tag