HTML <meta> 标签的 http-equiv 属性

实例

每 30 秒刷新一次文档:

<head>
  <meta http-equiv="refresh" content="30">
</head>

亲自试一试

定义和用法

http-equiv 属性为 content 属性的信息/值提供 HTTP 标头。

http-equiv 属性可用于模拟 HTTP 响应标头。

浏览器支持

属性ChromeInternet Explorer / EdgeFirefoxSafariOpera
http-equivYesYesYesYesYes

语法

<meta http-equiv="content-security-policy|content-type|default-style|refresh">

属性值

描述
content-security-policy

规定文档的内容策略。

例子:

<meta http-equiv="content-security-policy" content="default-src 'self'">

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 属性的值必须与同一文档中链接元素的 title 属性值匹配,或者必须与同一文档中 style 元素的 title 属性值匹配。

refresh

定义文档自我刷新的时间间隔。

例子:

<meta http-equiv="refresh" content="300">

注释:应谨慎使用值 "refresh",因为它会从用户手中夺走页面的控制权。使用 "refresh" 将导致 W3C 的 Web 内容可访问性指南失败。