What is the usage of base in html5
Feb 03, 2023 am 10:13 AMThe 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 <base> element can be used, and it must be located in <head> Inside the element, its usage is as follows: "<head><meta charset="utf-8"> <title></title><base href="..." target="_blank"> </head>”.
The operating environment of this tutorial: Windows 10 system, HTML5 version, DELL G3 computer
What is the usage of base in html5? The
<base> tag specifies the default URL or default target for all relative links on the page.
In a document, at most one <base> element can be used. The <base> tag must be inside the <head> element.
Tip: Please place the <base> tag as the first element in the <head> element, so that other elements in the head area can use the information in the <base> element.
Note: If the <base> 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>
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!

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Base Dawgz ($DAWGZ) multichain token launched on decentralized exchanges today
