Home > Web Front-end > Front-end Q&A > What is the usage of base in html5

What is the usage of base in html5

藏色散人
Release: 2023-02-03 10:13:26
Original
1787 people have browsed it

The function of the base tag in html5 is to specify the default URL or default target for all relative links on the page. In a document, up to one element can be used, and it must be located in Inside the element, its usage is as follows: " ”.

What is the usage of base in html5

The operating environment of this tutorial: Windows 10 system, HTML5 version, DELL G3 computer

What is the usage of base in html5? The

tag specifies the default URL or default target for all relative links on the page.

In a document, at most one element can be used. The tag must be inside the element.

Tip: Please place the tag as the first element in the element, so that other elements in the head area can use the information in the element.

Note: If the tag is used, it must have the href attribute or the target attribute or both attributes.

Example

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

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"> 
<title></title>
<base href="//www.w3cschool.cn/statics/images/w3c/" target="_blank">
</head>
<body>

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

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

</body>
</html>
Copy after login

Recommended learning: "HTML Video Tutorial

The above is the detailed content of What is the usage of base in html5. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template