HTML笔记(七)head相关元素 &

  <head>元素是所有头部元素的容器。

  可添加的标签有:<title>、<base>、<link>、<meta>、<script>和<style>。

  • <base>元素

  <base>标签规定了页面上的所有链接的默认地址或默认目标target。

<html>
<head>
    <base href="http://www.w3school.com.cn/i/" />
    <base target="_blank" />
</head>

<body>
    <!-- head部分已经规定了一个基准UR。 -->
    <img src="eg_smile.gif" />

    <p><a href="http://www.w3school.com.cn">W3School</a></p>
</body>
</html>
  • <meta>元素

  <meta>元素提供有关页面的元信息meta-infomation,如针对搜索引擎和更新频率的描述好关键字。

  <mata>不包含任何内容,其属性定义了与文档相关联的键 / 值对。

  所有服务器至少要发送一个:content-type: text/html。

  content属性主要是为键 / 值对提供值。它必须和name属性或者http-equiv属性一起使用。

  name属性和content属性

  name属性主要为键 / 值对提供键的名称。支持的属性值包括:author、description、keywords、generator、revised和others。

<meta name="author"content="X" />
<meta name="revised" content="X,9/1/15" />
<meta name="generator "content="Aptana 3.0" />
<meta name="keywords" content="Hello,Speak,Human,Computer" />
<meta name="description"content="This is a test." />

  ② http-equiv属性和content属性

  http-equiv属性主要为键 / 值对提供键的名称。支持的属性值包括:content-type、expires、refresh和set-cookie等。

  content属性主要是为键 / 值对提供值。它必须和name属性或者http-equiv属性一起使用。

  当服务器向浏览器发送文档时,会先发送多个键 / 值对。

  更多细节

<meta http-equiv="Content-Type" content="text/html />
<meta http-equiv="charset" content="gb2312" />
<meta http-equiv="expires" content="Wed, 20 Jun 2007 22:33:00 GMT" />
<meta http-equiv="Refresh" content="2;URL=http://www.net.cn/" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Set-Cookie" content="cookievalue=xxx;expires=Wednesday, 20-Jun-2007 22:33:00 GMT; path=/"  />
<meta http-equiv="Window-target" content="_top"/>