首页 > Web开发 > 详细

HTML/Elements/base

时间:2017-01-06 01:00:45      阅读:335      评论:0      收藏:0      [点我收藏+]

https://www.w3.org/wiki/HTML/Elements/base

HTML/Elements/base

HTML? | Elements
 

<base>

The <base> element allows authors to specify the document base URL for the purposes of resolving relative URLs, and the name of the default browsing context for the purposes of following hyperlinks. The element does not represent any content beyond this information.

Point

  • A base element must have either an href attribute, a target attribute, or both.
  • There must be no more than one base element per document.

 

HTML Attributes

  • href = valid URL potentially surrounded by spaces
    A base element, if it has an href attribute, must come before any other elements in the tree that have attributes defined as taking URLs, except the html element (its manifest attribute isn‘t affected by base elements). [Example A]
  • target = valid browsing context name or keyword ( _blank, _self, _parent, or _top)
    The value of the target attribute is used as the default when hyperlinks and forms in the Document cause navigation.

See also global attributes.

Examples

Example A

In this example, a <base> element is used to set the document base URL.
The link in the this example would be a link to "http://www.example.com/news/archives.html" [try it]:

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>This is an example for the <base> element</title>
        <base href="http://www.example.com/news/index.html">
    </head>
    <body>
        <p>Visit the <a href="archives.html">archives</a>.</p>
    </body>
</html>

技术分享

HTML Reference

The HTML5 specification defines the <base> element in 4.2.3 The base element.

HTML/Elements/base

原文:http://www.cnblogs.com/yuanjiangw/p/6254577.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!