Standard metadata names - HTML: HyperText Markup Language 编辑

The <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.

Standard metadata names defined in the HTML specification

The HTML specification defines the following set of standard metadata names:

  • application-name: the name of the application running in the web page.

    Note:
    • Browsers may use this to identify the application. It is different from the <title> element, which usually contain the application name, but may also contain information like the document name or a status.
    • Simple web pages shouldn't define an application-name.
  • author: 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.
  • generator: the identifier of the software that generated the page.
  • keywords: words relevant to the page's content separated by commas.
  • referrer: controls the HTTP Referer header for to requests sent from the document:
    Values for the content attribute of <meta name="referrer">
    no-referrerDo not send a HTTP Referer header.
    originSend the origin of the document.
    no-referrer-when-downgradeSend 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-originSend the full URL (stripped of parameters) for same-origin requests, but only send the origin for other cases.
    same-originSend the full URL (stripped of parameters) for same-origin requests. Cross-origin requests will contain no referrer header.
    strict-originSend 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-originSend 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-URLSend the full URL (stripped of parameters) for same-origin or cross-origin requests.
    Notes:
    • Dynamically inserting <meta name="referrer"> (with document.write() or appendChild()) makes the referrer behaviour unpredictable.
    • When several conflicting policies are defined, the 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.

    The value of the content property for color-scheme may be one of the following:

    normal
    The document is unaware of color schemes and should 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
    Indicates that the document only supports light mode, with a light background and dark foreground colors. By specification, 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.

Standard metadata names defined in other specifications

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.

    Values for the content of <meta name="viewport">
    ValuePossible subvaluesDescription
    widthA positive integer number, or the text device-widthDefines the pixel width of the viewport that you want the web site to be rendered at.
    heightA positive integer, or the text device-heightDefines the height of the viewport. Not used by any browser.
    initial-scaleA positive number between 0.0 and 10.0Defines the ratio between the device width (device-width in portrait mode or device-height in landscape mode) and the viewport size.
    maximum-scaleA positive number between 0.0 and 10.0Defines 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-scaleA positive number between 0.0 and 10.0Defines 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-scalableyes or noIf set to 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-fitauto, contain or cover

    The auto value doesn’t affect the initial layout viewport, and the whole web page is viewable.

    The contain value means that the viewport is scaled to fit the largest rectangle inscribed within the display.

    The cover value means that the viewport is scaled to fill the device display. It is highly recommended to make use of the safe area inset variables to ensure that important content doesn't end up outside the display.

    Notes:
    • Though unstandardized, this declaration is respected by most mobile browsers due to de-facto dominance.
    • The default values may vary between devices and browsers.
    • To learn about this declaration in Firefox for Mobile, see this article.
    Accessibility concerns with viewport scaling
    Disabling zooming capabilities by setting user-scalable to a value of no prevents people experiencing low vision conditions from being able to read and understand page content.
    See also

    The @viewport CSS at-rule.

Other metadata names

The 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:
    Values for the content of <meta name="robots">
    ValueDescriptionUsed by
    indexAllows the robot to index the page (default).All
    noindexRequests the robot to not index the page.All
    followAllows the robot to follow the links on the page (default).All
    nofollowRequests the robot to not follow the links on the page.All
    allEquivalent to index, followGoogle
    noneEquivalent to noindex, nofollowGoogle
    noarchiveRequests the search engine not to cache the page content.Google, Yahoo, Bing
    nosnippetPrevents displaying any description of the page in search engine results.Google, Bing
    noimageindexRequests this page not to appear as the referring page of an indexed image.Google
    nocacheSynonym of noarchive.Bing
    Notes:
    • Only cooperative robots follow these rules. Do not expect to prevent e-mail harvesters with them.
    • The robot still needs to access the page in order to read these rules. To prevent bandwidth consumption, use a robots.txt file.
    • If you want to remove a page, noindex will work, but only after the robot visits the page again. Ensure that the robots.txt file is not preventing revisits.
    • Some values are mutually exclusive, like index and noindex, or follow and nofollow. In these cases the robot's behaviour is undefined and may vary between them.
    • Some crawler robots, like Google, Yahoo and Bing, support the same values for the HTTP header X-Robots-Tag; this allows non-HTML documents like images to use these rules.

Specifications

Specification
HTML Living Standard
The definition of 'standard metadata names' in that specification.
CSS Device Adaptation
The definition of 'the "viewport" metadata name' in that specification.
Referrer Policy
The definition of 'the "referrer" metadata name' in that specification.

Browser compatibility

BCD tables only load in the browser

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:39 次

字数:17855

最后编辑:6 年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文