網頁

2013年3月26日

[html] meta標籤

meta必須置放於<head></head>中間,標籤使用的屬性有三種,分別如下:
http-equiv 用途在對網頁檔案輸出的檔頭敘述,讓瀏覽器可以順利處理。
name 主要針對網頁內容做說明,搜尋引擎大都收錄此摘要。
scheme 自定屬性值格式(不常用)。


http-equiv範例:
頁面編碼方式,可以讓瀏覽器自動切換Big5編碼。
<meta http-equiv="Content-Type" content="text/html; charset=big5">

頁面語系,簡體zh-CN、繁體zh-TW或英文en-US。
<meta http-equiv="Content-Language" content="zh-TW">

頁面重新整理,每10秒就更新http://blog.nux.tw/這頁面,或是用於轉址。
<meta http-equiv="Refresh" content="10;url=http://blog.nux.tw">

頁面有效時間,當頁面超過指定的時間,就會重新向主機索取頁面,否則是直接讀取快取頁面。
<meta http-equiv="Expires" content="Sun,31 Mar 2013 20:00:00 GMT">
或 <meta http-equiv="Expires" content="0"> (立即過期)

設定頁面沒有快取,每次都必須向主機重新讀取,所以較耗頻寬。
<meta http-equiv="Cache-Control" content="no-cache">
或 <meta http-equiv="Pragma" content="no-cache"> (舊式寫法)

頁面有效時間,超過指定時間快取檔案會被刪除(與Expires的差異)。
<meta http-equiv="set-cookie" content="Sun,31 Mar 2013 20:00:00 GMT">


name範例:
網頁內容關鍵字。
<meta name="keywords" content="關鍵字">

網頁內容簡單敘述。
<meta name="description" content="內容簡述">

網頁作者。
<meta name="author" content="作者姓名">

網頁編輯工具。
<meta name="generator" content="Notepad ++">

網頁著作權宣告。
<meta name="copyright" content="....著作權宣告....">

網頁發佈地點
<meta name="distribution" content="Asia Taiwan">

網頁網址
<meta name="url" content="http://blog.nux.tw/">

對網頁機器人做檢索敘述,有6種方式。
<meta name="robots" content="all">
all:全部可以收錄。
none:全部(頁面及超鏈結)禁止收錄,與使用noindex:nofollow等同效果。
index:只有頁面可以被收錄。
follow:只有超鏈結可以被收錄。
noindex:頁面禁止收錄,但超鏈結可以被收錄。
nofollow:超鏈結禁止收錄,但頁面可以被收錄。

自定屬性值格式
<meta name="date" content="2009-01-02" scheme="YYYY-MM-DD">