练习题: 做百度首页的导航栏
如图所示:

怎样写?
波利亚《怎样解题》:"你以前见过它吗?你是否见过相同的问题而形式稍有不同?"意思就是你可以看看别人是怎么写的,照葫芦画瓢。

代码如下:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>a标签</title>
</head>
<body>
<a href="http://news.baidu.com" target="_blank">新闻
</a>
<a href="https://www.hao123.com" target="_blank">hao123
</a>
<a href="http://map.baidu.com" target="_blank">地图
</a>
<a href="http://tieba.baidu.com" target="_blank">贴吧
</a>
<a href="http://xueshu.baidu.com" target="_blank">学术
</a>
</body>
</body>
</html>
运行结果如下:

base标签
作用:
专门用来统一指定当前网页中所有的超链接(a标签)需要如何打开
格式如下:
<base target="_blank">
注意点:
1.写在<head></head>里面
2.如果既在base中指定了target又在a标签中指定了target那么浏览器会按照a标签中指定的来执行
代码如下:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>a标签</title>
<base target="_blank">
</head>
<body>
<a href="http://news.baidu.com" target="_self">新闻
</a>
<a href="https://www.hao123.com" >hao123
</a>
<a href="http://map.baidu.com" >地图
</a>
<a href="http://tieba.baidu.com" >贴吧
</a>
<a href="http://xueshu.baidu.com">学术
</a>
</body>
</body>
</html>
网友评论