<base>
HTML <base> Tag
Instance
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>php中文网(php.cn)</title> <base href="//m.sbmmt.com//images/" target="_blank"> </head> <body> <p><img src="logo.png" > - 注意这里我们设置了图片的相对地址。能正常显示是因为我们在 head 部分设置了 base 标签,该标签指定了页面上所有链接的默认 URL,所以该图片的访问地址为 "//m.sbmmt.com/images/logo.png"</p> <p><a href="//m.sbmmt.com/">php.cn</a> - 注意这个链接会在新窗口打开,即便它没有 target="_blank" 属性。因为在 base 标签里我们已经设置了 target 属性的值为 "_blank"。</p> </body> </html>
Run Example»
Click the "Run Instance" button to view the online instance
Browser support
##All major browsers support the <base> tag .Tag definition and usage instructions<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 a <head> element.
Tips and Notes
Tips: Please place the <base> tag in the <head> elementFirst The position of the 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.
Differences between HTML 4.01 and HTML5None.
Differences between HTML and XHTMLIn HTML, the <base> tag does not have a closing tag. In XHTML, the <base> tag must be closed properly.
Properties
Value | Description | |
---|---|---|
URL | Specifies the base URL of all relative links in the page.||
_blank |
_parent _self _top framename | specifies where all hyperlinks and forms in the page will be opened. This attribute is overridden by the target attribute in each link.