Latest web development tutorials

HTML meta http-equiv attribute

HTML meta tags Reference Manual HTML <meta> tag

Examples

Every 30 seconds to refresh the document:

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

try it"

Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support http-equiv attribute.


Definition and Usage

http-equiv attribute provides Content the HTTP header / value of the property.

http-equiv attribute can be used to simulate a HTTP response header.


Differences between HTML 4.01 and HTML5

Http-equiv only way to use the character set is not specified in an HTML document:

  • HTML 4.01: <meta http-equiv = "content-type" content = "text / html; charset = UTF-8">
  • HTML5: <meta charset = "UTF-8">

grammar

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

Property Value

描述
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" 会到导致失败。



HTML meta tags Reference Manual HTML <meta> tag