HTML基础:基本标签简介(3)

html中有很多标签,下面介绍最基本的几个标签。


1、meta

是head标签中的一个辅助性标签。

有2个重要属性:

(1)name

可以优化页面被搜索到的可能性。name中可以指定属性,content是属性值。

<html>
	<head>
		<meta name="keywords" content="python,编程">
			<!- 搜索引擎的关键字说明 ->

		<meta name="description" content="学习python编程">
			<!- 搜索引擎说明主要内容 ->

		<meta name="generator" content="python.exe">
			<!- 向页面说明生成的软件 ->

		<meta name="author" content="yupeigu">
			<!- 向页面说明作者 ->

		<meta name="robots" content="all">
			<!- 向页面说明限制搜索的方式 ->
	</head>
</html>

(2)http-equiv

反馈给浏览器一些明确的信息,帮助浏览器更加精确的显示页面,会把content属性关联到http头。

<html>
	<head>
		<meta http-equiv="content-type" content="text/html; charset=gb2312">
	</head>
</html>

说明了这个页面使用的字符集是gb2312,如果浏览这个网页时,电脑中么没有gb2312字符集,浏览器会提示需要下载 汉语支持。

另外,http-equiv还有一些特殊的效果,下面代码可以实现网页定时跳转:

<html>
	<head>
		<title>网页跳转</title>
		<meta http-equiv="refresh" content="6; url=http://www.baidu.com"></meta>
	</head>
	<body>
		6秒后,网页会自动跳转到 www.baidu.com ...
	</body>
</html>

效果就像在网页中显示的一样,http-equiv设置为刷新,内容是6秒钟,要刷新到 百度首页。


2、link

给页面定义了一个外部文件的链接,可以用来链接外部的css样式,比如:

<html>
	<head>
		<link rel="stylesheet" type="text/css" href="/html/csstest1.css" >
	</head>
</html>

其中rel属性指出被链接的文档是一个样式表,类型是css,链接是文件: /html/csstest1.css


3、base

定义页面所有链接的基础定位,确保文档中所有的相对url,都能分解成正确的文档地址:

<html>
	<head>
		<base href="http://blog.csdn.net/">
		<base target="_blank">
	</head>
	<body>
		<a href="sqlserverdiscovery/">我的blog</a>
	</body>
</html>

点击超链接,就会跳转到 我的csdn博客,base标签类似于基础路径,合并之后就是:http://blog.csdn.net/sqlserverdiscovery/

另外,target属性指定了在何处打开这个链接,_blank就是弹出新的网页,而不是在当前网页中显示。


4、style

style定义css样式,比如:

<style type="text/css">
	.style1 {
		font-size: 20px;
		font-weight: bold;
		color: #FFFFFF;
	}
</style>

上面定义了class属性值为 style1的标签的样式,包括:文字大小,粗体,字的颜色。


5、script

用来定义页面中的脚本,比如:javascript脚本,通过这个标签就可以放到html中:

<script type="text/javascript">
</script>


6、title

title用来定义网页的标题,也就是网页的名字,如果不定义,就显示Untitled Document。

<!DOCTYPE html>
<html>
	<head>
		<title>网页的名字</title>
	</head>
</html>


7、body

body标签定义了网页主体内容的开始、结束,也就是大家在浏览器中看到的网页内容,另外,大部分的标签都能放到body标签中。

<!DOCTYPE html>
<html>
	<head>
		<title>网页的名字</title>
	</head>
	<body>
		这里是网页的内容,是网页的关键。
	</body>
</html>


原文地址:https://www.cnblogs.com/momogua/p/8304379.html