Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

HTML <base> tags


May 04, 2021 HTML Reference Manual


Table of contents


HTML tags

The label is the baseline URL tag in the HTML language and is a single label.

The label is located within the .lt;head?gt; label of the page header file, and a page can use up to one base element to provide a specified default target.

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

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>W3Cschool(w3cschool.cn)</title>
<base href="https://www.w3cschool.cn/statics/images/"; target="_blank">
</head>
<body>
<p><img src="logo.png" > - 注意这里我们设置了图片的相对地址。能正常显示是因为我们在 head 部分设置了 base 标签,该标签指定了页面上所有链接的默认 URL,所以该图片的访问地址为 "https://www.w3cschool.cn/statics/images/logo.png";

<p><a href="https://www.w3cschool.cn/">w3cschool.cn</a>- 注意这个链接会在新窗口打开,即便它没有 target="_blank" 属性。因为在 base 标签里我们已经设置了 target 属性的值为 "_blank"。</p>

</body>
</html>
Try it out . . .

Browser support

HTML <base> tags HTML <base> tags HTML <base> tags HTML <base> tags HTML <base> tags

All major browsers support the label.


Label definition and instructions for use

The label specifies the default URL or default destination for all relative links on the page.

You can use up to one element in a document. T he label must be inside the element.


Tips and comments

Tip: Please put the label in the position of the first element in the element so that the information in the element can be used by the other elements in the head area.

Note: If you are using the label, you must have the href property or the target property or both properties.


The difference between HTML 4.01 and HTML5

No.


The difference between HTML and XHTML

In HTML, the label does not have an end label.

In XHTML, the label must be turned off correctly.


Property

Property Value Describe
Href Url Specifies the baseline URL for all relative links on the page.
target _blank
_parent
_self
_top
framename
Specify where all hyperlinks and forms in the page open. The property is overwritten by the target property in each link.


Global properties

The label supports the global properties of HTML.


The event property

The label does not support any event properties.


Related articles

HTML DOM Reference Manual: Base Object