HTML Dog
跳至导航

HTML 标签:base

页面上的链接应基于的基础位置

文档内的相对链接(例如 <a href="someplace.html"…<img src="someimage.jpg"…)将相对于 base 元素指定的 URL。

如果使用,base 元素必须放在 head 元素内,并且只能使用一次。

可选属性

属性 描述 可能的值
href 生成相对链接的文档基础地址。 URL。
target 链接应打开的浏览上下文。
  • _self:将在当前窗口/标签页中打开链接。
  • _blank:将在新窗口/标签页中打开链接。
全局属性

示例


<head>
    <title>Peppers</title>
    <base href="http://www.somedomain.com/someDirectory/">
</head>
<body>
    <p><a href="somePlace.html">This</a> will actually link to http://www.somedomain.com/someDirectory/somePlace.html.</p>
    <div><img src="someImage.jpg" alt="Some image"></div>
    <p> The location of the above image will be actually be http://www.somedomain.com/someDirectory/someImage.jpg.</p>
</body>