HTML <head>
元素
<head>
元素是所有頭部元素的容器。<head>
內的元素可包含腳本,指示瀏覽器在何處可以找到樣式表,提供元信息,等等。
以下標簽都可以添加到 head 部分:<title>
、<base>
、<link>
、<meta>
、<script>
以及 <style>
。
HTML <title>
元素
<title>
標簽定義文檔的標題。
<title>
元素能夠:
- 定義瀏覽器工具欄中的標題
- 提供頁面被添加到收藏夾時顯示的標題
- 顯示在搜索引擎結果中的頁面標題
HTML <link>
元素
<link>
標簽定義文檔與外部資源之間的關系。
<link>
標簽最常用于鏈接樣式表。
1、文檔的標題
<title>
定義文檔的標題。
2、所有鏈接一個目標
使用 base 標簽使頁面中的所有標簽在新窗口中打開。
<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 target="_blank">這個連接</a> 將在新窗口中加載,因為 target 屬性被設置為 "_blank"。
</p>
<p>
<a >這個連接</a> 也將在新窗口中加載,即使沒有 target 屬性。
</p>
</body>
</html>
3、文檔描述
使用 <meta>
元素來描述文檔。
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<meta name="author" content="w3school.com.cn" />
<meta name="revised" content="SWB,4/18/2017">
<meta name="generator" content="Dreamweaver 8.0en">
<base target="_blank" />
</head>
<body>
<p>本文檔的 meta 屬性標識了創作者和編輯軟件。</p>
</body>
</html>
4、文檔關鍵詞
使用 <meta>
元素來定義文檔的關鍵詞。
<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 屬性描述了該文檔和它的關鍵詞。</p>
</body>
</html>
5、重定向用戶
自動跳轉到新的網址。
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<meta http-equiv="Refresh" content="5;url=https://www.baidu.com/" />
</head>
<body>
<p>
對不起。我們已經搬家了。您的 URL 是 <a >https://www.baidu.com/</a>
</p>
<p>您將在 5 秒內被重定向到新的地址。</p>
<p>如果超過 5 秒后您仍然看到本消息,請點擊上面的鏈接。</p>
</body>
</html>