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
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
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:
content-security-policy
Allows page authors to define a content policy for the current page. Content policies mostly specify allowed server origins and script endpoints which help guard against cross-site scripting attacks.
content-type
Declares the
MIME 类型
and character encoding of the document. If specified, the
content
attribute must have the value "
text/html; charset=utf-8
". This is equivalent to a
meta
element with the
charset
attribute specified, and carries the same restriction on placement within the document.
注意:
Can only be used in documents served with a
text/html
— not in documents served with an XML MIME type.
default-style
Sets the name of the default CSS style sheet set.
x-ua-compatible
If specified, the
content
attribute must have the value "
IE=edge
". User agents are required to ignore this pragma.
refresh
This instruction specifies:
content
attribute contains a positive integer.
content
attribute contains a positive integer followed by the string '
;url=
', and a valid URL.
refresh
value run the risk of having the time interval being too short. People navigating with the aid of assistive technology such as a screen reader may be unable to read through and understand the page's content before being automatically redirected. The abrupt, unannounced updating of the page content may also be disorienting for people experiencing low vision conditions.
名称
名称
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. |
实时标准 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
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 |
完整支持