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
Inside the element, its usage is as follows: "element can be used, and it must be located in ”.
The operating environment of this tutorial: Windows 10 system, HTML5 version, DELL G3 computer
What is the usage of base in html5? The
In a document, at most one
Tip: Please place the
Note: If the
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>
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!