What is the function of base tag in html

云罗郡主
Release: 2019-01-31 16:44:00
Original
5115 people have browsed it

What is the role of the base tag in html?

Function: Specifies the default address or default target for all links on the page. It is a label that expresses the path and connection URL.

Note: Normally, the browser will extract the corresponding elements from the URL of the current document to fill in the blanks in the relative URL. This can be changed using the tag. The browser will then no longer use the URL of the current document, but will use the specified base URL to resolve all relative URLs. This includes URLs in , , ,

tags.

Note: In HTML, the tag does not have a closing tag; in XHTML, the tag must be closed correctly. The tag must be inside the head element.

html base tag example

<head>
<base href="http://www.php.cn/tpl/Index/Static/img/" />
<base target="_blank" />
</head>
<body>
<img src="banner7.jpg" /><br />
<p>请注意,我们已经为图像规定了一个相对地址。由于我们已经在 head 部分规定了一个基准 URL,浏览器将在如下地址寻找图片:</p>
<p>"http://www.php.cn/tpl/Index/Static/img/banner7.jpg"</p>
<br /><br />
<p><a href="http://www.php.cn">php中文网</a></p>
<p>请注意,链接会在新窗口中打开,即使链接中没有 target="_blank" 属性。这是因为 base 元素的 target 属性已经被设置为 "_blank" 了。</p>
</body>
</html>
Copy after login


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

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!