base元素的用法

简介

base元素可以用来设置一个基准URL,HTML文档中的相对链接就可以在此基础上进行解析。
base元素有2个属性:
href:设置基准URL
target: 设置链接在用户点击时的代开方式

用法

<!document html>
<html lang="zh-CN">
    <head>
        <title>base标签</title>
        <meta charset="utf-8">
        <base href="http://localhost:8090/test/img/" target="_blank"/>
    </head>
    <body>
        <img src="1.jpg" width="200" height="125"/>
        <p/>
        <a href="http://www.baidu.com">百度一下</a>
    </body>
</html>
img元素的src标签会自动解析base的基准URL,以便获取图片
a元素从base元素获取了打开链接的方式,以新窗口打开链接

猜你喜欢

转载自blog.csdn.net/harmsworth2016/article/details/81050881
今日推荐