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

    注意:
    • 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.
  • 作者 : 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:
    Values for the content attribute of <meta name="referrer">
    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.
    注意事项:
    • 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.

    值对于 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
    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">
    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.

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

    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.

    注意事项:
    • 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.

    另请参阅

    @viewport CSS at-rule.

Other metadata names

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">
    描述 用于
    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 Google
    none 相当于 noindex, nofollow Google
    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. Google
    nocache 同义词的 noarchive . Bing
    注意事项:
    • 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 文件。
    • 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 ,或 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.

规范

规范
HTML 实时标准
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.

浏览器兼容性

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
名称 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 注意事项
完整支持 17 注意事项
注意事项 Until Chrome 46, content values weren't constrained to the values listed in the spec.
Edge 完整支持 79 Firefox 完整支持 36 注意事项
完整支持 36 注意事项
注意事项 referrer value wasn't taken into account when navigation was happening via the context menu or middle click until Firefox 39.
IE ? Opera 完整支持 15 注意事项
完整支持 15 注意事项
注意事项 Until Opera 46, content values weren't constrained to the values listed in the spec.
Safari ? WebView Android 完整支持 37 注意事项
完整支持 37 注意事项
注意事项 Until Chrome 46, content values weren't constrained to the values listed in the spec.
Chrome Android 完整支持 18 注意事项
完整支持 18 注意事项
注意事项 Until Chrome 46, content values weren't constrained to the values listed in the spec.
Firefox Android 完整支持 36 注意事项
完整支持 36 注意事项
注意事项 referrer value wasn't taken into account when navigation was happening via the context menu or middle click until Firefox 39.
Opera Android ? Safari iOS ? Samsung Internet Android 完整支持 1.0 注意事项
完整支持 1.0 注意事项
注意事项 Until Samsung Internet 5.0, content values weren't constrained to the values listed in the spec.
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 注意事项
部分支持 73 注意事项
注意事项 Desktop Chrome only uses the color on installed progressive web apps. (Per caniuse.com.)
不支持 39 — 72 注意事项
注意事项 Desktop Chrome 39-72 claimed to have support, but did not actually use the color anywhere. Chrome for Android did use the color in the toolbar. (Per caniuse.com.)
Edge 不支持 No Firefox 不支持 No IE 不支持 No Opera 不支持 No Safari 不支持 No WebView Android 不支持 No Chrome Android 完整支持 80 注意事项
完整支持 80 注意事项
注意事项 Chrome for Android does not use the color on devices with native dark-mode enabled. (Per caniuse.com.)
Firefox Android 不支持 No Opera Android 不支持 No Safari iOS 不支持 No Samsung Internet Android 完整支持 6.2

图例

完整支持

完整支持

部分支持

部分支持

不支持

不支持

兼容性未知 ?

兼容性未知

弃用。不要用于新网站。

弃用。不要用于新网站。

见实现注意事项。

见实现注意事项。

元数据

  • 最后修改:
  1. <base>
  2. <head>
  3. <link>
  4. <meta>
  5. <style>
  6. <title>
  7. HTML 元素
    1. A
      1. <a>
      2. <abbr>
      3. <acronym>
      4. <address>
      5. <applet>
      6. <area>
      7. <article>
      8. <aside>
      9. <audio>
    2. B
      1. <b>
      2. <base>
      3. <basefont>
      4. <bdi>
      5. <bdo>
      6. <bgsound>
      7. <big>
      8. <blink>
      9. <blockquote>
      10. <body>
      11. <br>
      12. <button>
    3. C
      1. <canvas>
      2. <caption>
      3. <center>
      4. <cite>
      5. <code>
      6. <col>
      7. <colgroup>
      8. <content>
    4. D
      1. <data>
      2. <datalist>
      3. <dd>
      4. <del>
      5. <details>
      6. <dfn>
      7. <dialog>
      8. <dir>
      9. <div>
      10. <dl>
      11. <dt>
    5. E
      1. <em>
      2. <embed>
    6. F
      1. <fieldset>
      2. <figcaption>
      3. <figure>
      4. <font>
      5. <footer>
      6. <form>
      7. <frame>
      8. <frameset>
    7. G H
      1. <h1>
      2. <h2>
      3. <h3>
      4. <h4>
      5. <h5>
      6. <h6>
      7. <head>
      8. <header>
      9. <hgroup>
      10. <hr>
      11. <html>
    8. I
      1. <i>
      2. <iframe>
      3. <img>
      4. <input>
      5. <ins>
      6. <isindex>
    9. J K
      1. <kbd>
      2. <keygen>
    10. L
      1. <label>
      2. <legend>
      3. <li>
      4. <link>
      5. <listing>
    11. M
      1. <main>
      2. <map>
      3. <mark>
      4. <marquee>
      5. <menu>
      6. <menuitem>
      7. <meta>
      8. <meter>
    12. N
      1. <nav>
      2. <nobr>
      3. <noframes>
      4. <noscript>
    13. O
      1. <object>
      2. <ol>
      3. <optgroup>
      4. <option>
      5. <output>
    14. P
      1. <p>
      2. <param>
      3. <picture>
      4. <plaintext>
      5. <pre>
      6. <progress>
    15. Q
      1. <q>
    16. R
      1. <rp>
      2. <rt>
      3. <rtc>
      4. <ruby>
    17. S
      1. <s>
      2. <samp>
      3. <script>
      4. <section>
      5. <select>
      6. <shadow>
      7. <slot>
      8. <small>
      9. <source>
      10. <spacer>
      11. <span>
      12. <strike>
      13. <strong>
      14. <style>
      15. <sub>
      16. <summary>
      17. <sup>
    18. T
      1. <table>
      2. <tbody>
      3. <td>
      4. <template>
      5. <textarea>
      6. <tfoot>
      7. <th>
      8. <thead>
      9. <time>
      10. <title>
      11. <tr>
      12. <track>
      13. <tt>
    19. U
      1. <u>
      2. <ul>
    20. V
      1. <var>
      2. <video>
    21. W
      1. <wbr>
    22. X Y Z
      1. <xmp>

版权所有  © 2014-2026 乐数软件    

工业和信息化部: 粤ICP备14079481号-1