<meta>
element can be used to provide document metadata in terms of name-value pairs, with the
name
attribute giving the metadata name, and the
content
attribute giving the value.
The HTML specification defines the following set of standard metadata names:
application-name
: the name of the application running in the web page.
<title>
element, which usually contain the application name, but may also contain information like the document name or a status.
作者
: the name of the document's author.
description
: a short and accurate summary of the content of the page. Several browsers, like Firefox and Opera, use this as the default description of bookmarked pages.
生成器
: the identifier of the software that generated the page.
关键词
: words relevant to the page's content separated by commas.
referrer
: controls the HTTP
Referer
header for to requests sent from the document:
no-referrer
|
Do not send a HTTP
Referer
头。
|
origin
|
发送 origin of the document. |
no-referrer-when-downgrade
|
Send the full URL when the destination is at least as secure as the current page (HTTP(S)→HTTPS), but send no referrer when it's less secure (HTTPS→HTTP). This is the default behaviour. |
origin-when-cross-origin
|
Send the full URL (stripped of parameters) for same-origin requests, but only send the origin for other cases. |
same-origin
|
Send the full URL (stripped of parameters) for same-origin requests. Cross-origin requests will contain no referrer header. |
strict-origin
|
Send the origin when the destination is at least as secure as the current page (HTTP(S)→HTTPS), but send no referrer when it's less secure (HTTPS→HTTP). |
strict-origin-when-cross-origin
|
Send the full URL (stripped of parameters) for same-origin requests. Send the origin when the destination is at least as secure as the current page (HTTP(S)→HTTPS). Otherwise, send no referrer. |
unsafe-URL
|
Send the full URL (stripped of parameters) for same-origin or cross-origin requests. |
<meta name="referrer">
(with
document.write()
or
appendChild()
) makes the referrer behaviour unpredictable.
no-referrer
policy is applied.
theme-color
: indicates a suggested color that user agents should use to customize the display of the page or of the surrounding user interface. The
content
attribute contains a valid CSS
<color>
.
color-scheme
: specifies one or more color schemes with which the document is compatible.
The browser will use this information in tandem with the user's browser or device settings to determine what colors to use for everything from background and foregrounds to form controls and scrollbars. The primary use for
<meta name="color-scheme">
is to indicate compatibility with—and order of preference for—light and dark color modes.
值对于
content
property for
color-scheme
may be one of the following:
normal
The document is unaware of color schemes and should simply be rendered using the default color palette.
light
|
dark
]+
One or more color schemes supported by the document. Specifying the same color scheme more than once has the same effect as specifying it only once. Indicating multiple color schemes indicates that the first scheme is preferred by the document, but that the second specified scheme is acceptable if the user prefers it.
only light
only dark
is not valid
, because forcing a document to render in dark mode when it isn't truly compatible with it can result in unreadable content; all major browsers default to light mode if not otherwise configured.
For example, to indicate that a document prefers dark mode but does render functionally in light mode as well:
<meta name="color-scheme" content="dark light">
This works at the document level in the same way that the CSS
color-scheme
property lets individual elements specify their preferred and accepted color schemes. Your styles can adapt to the current color scheme using the
prefers-color-scheme
CSS media feature.
The CSS Device Adaptation specification defines the following metadata name:
viewport
: gives hints about the size of the initial size of the
viewport
. Used by mobile devices only.
| 值 | Possible subvalues | 描述 |
|---|---|---|
width
|
A positive integer number, or the text
device-width
|
Defines the pixel width of the viewport that you want the web site to be rendered at. |
height
|
A positive integer, or the text
device-height
|
Defines the height of the viewport. Not used by any browser. |
initial-scale
|
A positive number between
0.0
and
10.0
|
Defines the ratio between the device width (
device-width
in portrait mode or
device-height
in landscape mode) and the viewport size.
|
maximum-scale
|
A positive number between
0.0
and
10.0
|
Defines the maximum amount to zoom in. It must be greater or equal to the
minimum-scale
or the behaviour is undefined. Browser settings can ignore this rule and iOS10+ ignores it by default.
|
minimum-scale
|
A positive number between
0.0
and
10.0
|
Defines the minimum zoom level. It must be smaller or equal to the
maximum-scale
or the behaviour is undefined. Browser settings can ignore this rule and iOS10+ ignores it by default.
|
user-scalable
|
yes
or
no
|
若设为
no
, the user is not able to zoom in the webpage. The default is
yes
. Browser settings can ignore this rule, and iOS10+ ignores it by default.
|
viewport-fit
|
auto
,
contain
or
cover
|
auto
value doesn’t affect the initial layout viewport, and the whole web page is viewable.
|
user-scalable
to a value of
no
prevents people experiencing low vision conditions from being able to read and understand page content.
@viewport
CSS at-rule.
WHATWG Wiki MetaExtensions page contains a large set of non-standard metadata names that have not been formally accepted yet; however, some of the names included there are already used quite commonly in practice — including the following:
creator
: the name of the creator of the document, such as an organization or institution. If there are more than one, several
<meta>
elements should be used.
googlebot
, a synonym of
robots
, is only followed by Googlebot (the indexing crawler for Google).
publisher
: the name of the document's publisher.
robots
: the behaviour that cooperative crawlers, or "robots", should use with the page. It is a comma-separated list of the values below:
| 值 | 描述 | 用于 |
|---|---|---|
index
|
Allows the robot to index the page (default). | 所有 |
noindex
|
Requests the robot to not index the page. | 所有 |
follow
|
Allows the robot to follow the links on the page (default). | 所有 |
nofollow
|
Requests the robot to not follow the links on the page. | 所有 |
all
|
相当于
index, follow
|
|
none
|
相当于
noindex, nofollow
|
|
noarchive
|
Requests the search engine not to cache the page content. | Google , Yahoo , Bing |
nosnippet
|
Prevents displaying any description of the page in search engine results. | Google , Bing |
noimageindex
|
Requests this page not to appear as the referring page of an indexed image. | |
nocache
|
同义词的
noarchive
.
|
Bing |
noindex
will work, but only after the robot visits the page again. Ensure that the
robots.txt
file is not preventing revisits.
index
and
noindex
,或
follow
and
nofollow
. In these cases the robot's behaviour is undefined and may vary between them.
X-Robots-Tag
; this allows non-HTML documents like images to use these rules.
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
名称
|
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 |
color-scheme
|
Chrome 完整支持 81 | Edge 完整支持 81 | Firefox 不支持 No | IE 不支持 No | Opera 完整支持 68 | Safari 完整支持 12.1 | WebView Android 完整支持 81 | Chrome Android 完整支持 81 | Firefox Android 不支持 No | Opera Android 不支持 No | Safari iOS 完整支持 12.2 | Samsung Internet Android 不支持 No |
referrer
|
Chrome
完整支持
17
注意事项
|
Edge 完整支持 79 |
Firefox
完整支持
36
注意事项
|
IE ? |
Opera
完整支持
15
注意事项
|
Safari ? |
WebView Android
完整支持
37
注意事项
|
Chrome Android
完整支持
18
注意事项
|
Firefox Android
完整支持
36
注意事项
|
Opera Android ? | Safari iOS ? |
Samsung Internet Android
完整支持
1.0
注意事项
|
scheme
弃用
|
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 |
theme-color
|
Chrome
部分支持
73
注意事项
|
Edge 不支持 No | Firefox 不支持 No | IE 不支持 No | Opera 不支持 No | Safari 不支持 No | WebView Android 不支持 No |
Chrome Android
完整支持
80
注意事项
|
Firefox Android 不支持 No | Opera Android 不支持 No | Safari iOS 不支持 No | Samsung Internet Android 完整支持 6.2 |
完整支持
部分支持
不支持
兼容性未知
弃用。不要用于新网站。
见实现注意事项。