HTML <meta> http-equiv 屬性
實例
每隔 30 秒刷新一次文檔:
<head>
<meta http-equiv="refresh" content="30">
</head>
<meta http-equiv="refresh" content="30">
</head>
流覽器支持
所有主流流覽器都支持 http-equiv 屬性。
定義和用法
http-equiv 屬性提供了 content 屬性的資訊/值的 HTTP 頭。
http-equiv 屬性可用於模擬一個 HTTP 回應頭。
HTML 4.01 與 HTML5之間的差異
使用 http-equiv 已經不是規定 HTML 文檔的字元集的唯一方式:
- HTML 4.01: <meta http-equiv="content-type" content="text/html; charset=UTF-8">
- HTML5: <meta charset="UTF-8">
語法
<meta http-equiv="content-type|default-style|refresh">
屬性值
值 | 描述 |
---|---|
content-type | 規定文檔的字元編碼。 實例: <meta http-equiv="content-type" content="text/html; charset=UTF-8"> |
default-style | 規定要使用的預定義的樣式表。 實例: <meta http-equiv="default-style" content="the document's preferred stylesheet"> 注釋:上面 content 屬性的值必須匹配同一文檔中的一個 link 元素上的 title 屬性的值,或者必須匹配同一文檔中的一個 style 元素上的 title 屬性的值。 |
refresh | 定義文檔自動刷新的時間間隔。
實例: <meta http-equiv="refresh" content="300"> 注釋:值 "refresh" 應該慎重使用,因為它會使得頁面不受用戶控制。在 W3C's Web 內容可訪問性指南 中使用 "refresh" 會到導致失敗。 |
