Home > Web Front-end > Front-end Q&A > How to use html base tag

How to use html base tag

藏色散人
Release: 2019-05-25 14:55:44
Original
2649 people have browsed it

html The base tag is used to specify the default address or default target for all links on the page. It is a tag that expresses the path and connection URL. Normally, the browser will extract the corresponding element from the URL of the current document. Fill in the blanks in relative URLs.

How to use html base tag

#html How to use base tag?

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 usage example

<html>
<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 How to use html base tag. 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