?
This document uses PHP Chinese website manual Release
文檔的標題
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <meta http-equiv="Content-Language" content="zh-cn" /> <title>標題不會顯示在文檔區(qū)</title> </head> <body> <p>這段文本會顯示出來。</p> </body> </html>
所有鏈接一個目標
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <meta http-equiv="Content-Language" content="zh-cn" /> <base target="_blank" /> </head> <body> <p> <a href="http://www.miracleart.cn" target="_blank">這個連接</a> 將在新窗口中加載,因為 target 屬性被設置為 "_blank"。 </p> <p> <a href="http://www.miracleart.cn">這個連接</a> 也將在新窗口中加載,即使沒有 target 屬性。 </p> </body> </html>
文檔描述
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <meta name="author" content="php.cn"> <meta name="revised" content="David Yang,8/1/07"> <meta name="generator" content="Dreamweaver 8.0en"> </head> <body> <p>本文檔的 meta 屬性標識了創(chuàng)作者和編輯軟件。</p> </body> </html>
文檔關(guān)鍵詞
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <meta name="description" content="HTML examples"> <meta name="keywords" content="HTML, DHTML, CSS, XML, XHTML, JavaScript, VBScript"> </head> <body> <p>本文檔的 meta 屬性描述了該文檔和它的關(guān)鍵詞。</p> </body> </html>
重定向用戶
<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <meta http-equiv="Refresh" content="5;url=http://www.miracleart.cn" /> </head> <body> <p> 對不起。我們已經(jīng)搬家了。您的 URL 是 <a href="http://www.miracleart.cn">http://www.miracleart.cn</a> </p> <p>您將在 5 秒內(nèi)被重定向到新的地址。</p> <p>如果超過 5 秒后您仍然看到本消息,請點擊上面的鏈接。</p> </body> </html>
<head> 元素是所有頭部元素的容器。<head> 內(nèi)的元素可包含腳本,指示瀏覽器在何處可以找到樣式表,提供元信息,等等。
以下標簽都可以添加到 head 部分:<title>、<base>、<link>、<meta>、<script> 以及 <style>。
<title> 標簽定義文檔的標題。
title 元素在所有 HTML/XHTML 文檔中都是必需的。
title 元素能夠:
定義瀏覽器工具欄中的標題
提供頁面被添加到收藏夾時顯示的標題
顯示在搜索引擎結(jié)果中的頁面標題
一個簡化的 HTML 文檔:
<!DOCTYPE html> <html> <head> <title>Title of the document</title> </head> <body> The content of the document...... </body> </html>
<base> 標簽為頁面上的所有鏈接規(guī)定默認地址或默認目標(target):
<head> <base href="http://www.miracleart.cn/images/" /> <base target="_blank" /> </head>
<link> 標簽定義文檔與外部資源之間的關(guān)系。
<link> 標簽最常用于連接樣式表:
<head> <link rel="stylesheet" type="text/css" href="mystyle.css" /> </head>
<style> 標簽用于為 HTML 文檔定義樣式信息。
您可以在 style 元素內(nèi)規(guī)定 HTML 元素在瀏覽器中呈現(xiàn)的樣式:
<head> <style type="text/css"> body {background-color:yellow} p {color:blue} </style> </head>
元數(shù)據(jù)(metadata)是關(guān)于數(shù)據(jù)的信息。
<meta> 標簽提供關(guān)于 HTML 文檔的元數(shù)據(jù)。元數(shù)據(jù)不會顯示在頁面上,但是對于機器是可讀的。
典型的情況是,meta 元素被用于規(guī)定頁面的描述、關(guān)鍵詞、文檔的作者、最后修改時間以及其他元數(shù)據(jù)。
<meta> 標簽始終位于 head 元素中。
元數(shù)據(jù)可用于瀏覽器(如何顯示內(nèi)容或重新加載頁面),搜索引擎(關(guān)鍵詞),或其他 web 服務。
一些搜索引擎會利用 meta 元素的 name 和 content 屬性來索引您的頁面。
下面的 meta 元素定義頁面的描述:
<meta name="description" content="Free Web tutorials on HTML, CSS, XML" />
下面的 meta 元素定義頁面的關(guān)鍵詞:
<meta name="keywords" content="HTML, CSS, XML" />
name 和 content 屬性的作用是描述頁面的內(nèi)容。
<script> 標簽用于定義客戶端腳本,比如 JavaScript。
我們會在稍后的章節(jié)講解 script 元素。
標簽 | 描述 |
---|---|
<head> | 定義關(guān)于文檔的信息。 |
<title> | 定義文檔標題。 |
<base> | 定義頁面上所有鏈接的默認地址或默認目標。 |
<link> | 定義文檔與外部資源之間的關(guān)系。 |
<meta> | 定義關(guān)于 HTML 文檔的元數(shù)據(jù)。 |
<script> | 定義客戶端腳本。 |
<style> | 定義文檔的樣式信息。 |