HTML <meta> element 表示 metadata that cannot be represented by other HTML meta-related elements, like <base> , <link> , <script> , <style> or <title> .

内容类别 Metadata content. If the itemprop attribute is present: flow content , 措词内容 .
准许内容 None, it is an empty element .
Tag omission As it is a void element, the start tag must be present and the end tag must not be present.
Permitted parents <meta charset> , <meta http-equiv> <head> element. If the http-equiv is not an encoding declaration, it can also be inside a <noscript> element, itself inside a <head> 元素。
Implicit ARIA role 无对应角色
Permitted ARIA roles No role permitted
DOM 接口 HTMLMetaElement

The type of metadata provided by the meta element can be one of the following:

  • name attribute is set, the meta element provides document-level metadata , applying to the whole page.
  • http-equiv attribute is set, the meta element is a pragma directive , providing information equivalent to what can be given by a similarly-named HTTP header.
  • charset attribute is set, the meta element is a charset declaration , giving the character encoding in which the document is encoded.
  • itemprop attribute is set, the meta element provides user-defined metadata .

属性

此元素包括 全局属性 .

注意: the attribute name has a specific meaning for the <meta> element, and the itemprop attribute must not be set on the same <meta> element that has any existing name , http-equiv or charset 属性。

charset
This attribute declares the document's character encoding. If the attribute is present, its value must be an ASCII case-insensitive match for the string " utf-8 ", because UTF-8 is the only valid encoding for HTML5 documents. meta elements which declare a character encoding must be located entirely within the first 1024 bytes of the document.
content
This attribute contains the value for the http-equiv or name attribute, depending on which is used.
http-equiv

Defines a pragma directive. The attribute is named http-equiv (alent) because all the allowed values are names of particular HTTP headers:

名称

名称 and content attributes can be used together to provide document metadata in terms of name-value pairs, with the 名称 attribute giving the metadata name, and the content attribute giving the value.

standard metadata names for details about the set of standard metadata names defined in the HTML specification.

范例

<meta charset="utf-8">
<!-- Redirect page after 3 seconds -->
<meta http-equiv="refresh" content="3;url=https://www.mozilla.org">
						

规范

规范 状态 注释
HTML 实时标准
The definition of '<meta>' in that specification.
实时标准

浏览器兼容性

The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
meta Chrome 完整支持 Yes Edge 完整支持 12 Firefox 完整支持 1 IE 完整支持 Yes Opera 完整支持 Yes Safari 完整支持 Yes WebView Android 完整支持 Yes Chrome Android 完整支持 Yes Firefox Android 完整支持 4 Opera Android 完整支持 Yes Safari iOS 完整支持 Yes Samsung Internet Android 完整支持 Yes
charset Chrome 完整支持 Yes Edge 完整支持 12 Firefox 完整支持 1 IE 完整支持 Yes Opera 完整支持 Yes Safari 完整支持 Yes WebView Android 完整支持 Yes Chrome Android 完整支持 Yes Firefox Android 完整支持 4 Opera Android 完整支持 Yes Safari iOS 完整支持 Yes Samsung Internet Android 完整支持 Yes
content Chrome 完整支持 Yes Edge 完整支持 12 Firefox 完整支持 1 IE 完整支持 Yes Opera 完整支持 Yes Safari 完整支持 Yes WebView Android 完整支持 Yes Chrome Android 完整支持 Yes Firefox Android 完整支持 4 Opera Android 完整支持 Yes Safari iOS 完整支持 Yes Samsung Internet Android 完整支持 Yes
http-equiv Chrome 完整支持 Yes Edge 完整支持 12 Firefox 完整支持 1 IE 完整支持 Yes Opera 完整支持 Yes Safari 完整支持 Yes WebView Android 完整支持 Yes Chrome Android 完整支持 Yes Firefox Android 完整支持 4 Opera Android 完整支持 Yes Safari iOS 完整支持 Yes Samsung Internet Android 完整支持 Yes
名称 Chrome 完整支持 Yes Edge 完整支持 12 Firefox 完整支持 1 IE 完整支持 Yes Opera 完整支持 Yes Safari 完整支持 Yes WebView Android 完整支持 Yes Chrome Android 完整支持 Yes Firefox Android 完整支持 4 Opera Android 完整支持 Yes Safari iOS 完整支持 Yes Samsung Internet Android 完整支持 Yes

图例

完整支持

完整支持

元数据

  • 最后修改: