所有的瀏覽器都支持meta標簽,用於提供頁面相關信息,信息都是以名(http-equiv和name標示)/值(content標示)對的形式現實。
屬性content,用於定義http-equiv(定義http頭部信息,服務器向瀏覽器提供的信息)和name(指定網頁信息的相關的名稱)相關的信息;
http-equiv就是在HTTP頭部指定了一些服務器返回給瀏覽器的有用信息
<meta http-equiv="參數" content="參數變量值">
屬性 | 值 | 作用 | |
http-equiv | content-type | 設置頁面的字符集 | <meta http-equiv="content-Type" content="text/html; charset=utf-8"> html5頁面的做法是直接使用<meta charset="utf-8"/> |
expires | 設置頁面的過期時間 | <meta http-equiv="expires" content="Wed, 20 Jun 2007 22:33:00 GMT"> | |
refresh | 自動刷新到新頁面 | <meta http-equiv="Refresh" content="2;URL=http://www.net.cn/"> //2代表頁面停留多長時間后跳轉都后面的網址上 |
|
set-cookie | 如果cookie過期,則自動刪除本地cookie | <meta http-equiv="Set-Cookie" content="cookievalue=xxx;expires=Wednesday, 20-Jun-2007 22:33:00 GMT; path=/"> | |
pragma | 禁止瀏覽器從本地調用緩存 | <meta http-equiv="Pragma" content="no-cache"> | |
window-target | 強制頁面在瀏覽器窗口獨立顯示 | <meta http-equiv="Window-target" content="_top"> | |
page_enter, page_exit | 設定進入頁面和退出頁面的效果 | <meta http-equiv="Page-Exit" contect="revealTrans(duration=1.0,transtion= 12)"> | |
cache-control | 清除緩存 | <meta http-equiv="cache-control" content="no-cache"> |
name把content的內容關聯到一個名稱上,html和xhtml都沒有執行固定的name值,可以自由使用對自己和源文檔的讀者來說富有意義的名稱
屬性 | 值 | 作用 | 實例 |
name | author | 指定頁面的所有者 | <meta name="author" content="James Bond"/> |
description | 頁面描述,用於搜索引擎收錄 | <meta name="description" content="中國設計網是中國起步最早的設計門戶網站,設計師的網上家園"/> | |
keywords | 頁面關鍵詞,用於被搜索引擎收錄 | <meta name="keywords" content="設計, 師妹"/> | |
generator | 用於說明網站制作生成工具 | <meta name="generator" content="Microsoft"/> | |
revised | 網頁文檔的修改時間 | <meta name="revised" content="設計網, 6/24/2015"/> | |
viewport | 用於控制頁面縮放 | <meta name=”viewport” content=”width=240, height=320, user-scalable=yes, initial-scale=2.5, maximum-scale=5.0, minimun-scale=1.0”> //width指定頁面的可視寬度, 像素值或device-width, initial-scale設置頁面初始化時的縮放比例,user-scalable指定是否可以縮放可視區域, maximum-scale, minimun-scale頁面最大最小縮放比例。 如果想要頁面在不同的設備都按照頁面的設計尺寸縮放(那些寬度固定的網站)就不要使用viewport屬性 | |
copyright | 網頁版權信息 | <meta name="copyright" name="Copyright 2015 Ironside"/> | |
renderer | 使用哪種模式顯示網頁 | <meta name="renderer" content="webkit|ie-comp|ie-stand"> webkit標示使用webkit內核打開頁面, ie-comp 使用IE兼容模式打開, |