The HTML <meta> element represents metadata that cannot be represented by other HTML meta-related elements, like <base>, <link>, <script>, <style> or <title>.
| Content categories | Metadata content. If the itemprop attribute is present: flow content, phrasing content. |
|---|---|
| Permitted 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>: a <head> element. If the http-equiv is not an encoding declaration, it can also be inside a <noscript> element, itself inside a <head> element. |
| Permitted ARIA roles | None |
| DOM interface | HTMLMetaElement |
Attributes
This element includes the global attributes.
Note: 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 attributes.
charset- This attribute declares the page's character encoding. It must contain a standard IANA MIME name for character encodings. Although the standard doesn't request a specific encoding, it suggests:
- Authors are encouraged to use
UTF-8. - Authors should not use ASCII-incompatible encodings to avoid security risk: browsers not supporting them may interpret harmful content as HTML. This happens with the
JIS_C6226-1983,JIS_X0212-1990,HZ-GB-2312,JOHAB, the ISO-2022 family and the EBCDIC family.
Note: ASCII-incompatible encodings are those that don't map the 8-bit code points
0x20to0x7Eto the0x0020to0x007EUnicode code points.- Authors must not use
CESU-8,UTF-7,BOCU-1and/orSCSUas cross-site scripting attacks with these encodings have been demonstrated. - Authors should not use
UTF-32because not all HTML5 encoding algorithms can distinguish it fromUTF-16.
Notes:- The declared character encoding must match the one the page was saved with to avoid garbled characters and security holes.
- The
<meta>element declaring the encoding must be inside the<head>element and within the first 1024 bytes of the HTML as some browsers only look at those bytes before choosing an encoding. - This
<meta>element is only one part of the algorithm to determine a page's character set. TheContent-Typeheader and any Byte-Order Marks override this element. - It is strongly recommended to define the character encoding. If a page's encoding is undefined, cross-scripting techniques are possible, such as the
UTF-7fallback cross-scripting technique. - The
<meta>element with acharsetattribute is a synonym for the pre-HTML5<meta http-equiv="Content-Type" content="text/html; charset=IANAcharset">, whereIANAcharsetcontains the value of the equivalentcharsetattribute. This syntax is still allowed, although no longer recommended.
- Authors are encouraged to use
content- This attribute contains the value for the
http-equivornameattribute, 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-language
Defines the default language of the page. It can be overridden by thelangattribute on any element.Warning: Do not use this value, as it is obsolete. Prefer the
langattribute on the<html>element.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
Defines the MIME type of the document, followed by its character encoding. It follows the same syntax as the HTTPcontent-typeentity-header field, but as it is inside a HTML page, most values other thantext/htmlare impossible. Therefore the valid syntax for itscontentis the string 'text/html' followed by a character set with the following syntax: '; charset=IANAcharset', whereIANAcharsetis the preferred MIME name for a character set as defined by the IANA.Note: As
<meta>can't change documents' types in XHTML or HTML5's XHTML serialization, never set the MIME type to an XHTML MIME type with<meta>.refresh
This instruction specifies:set-cookie
Defines a cookie for the page. Its content must follow the syntax defined in the IETF HTTP Cookie Specification.Warning: Do not use this instruction, as it is obsolete. Use the HTTP header
Set-Cookieinstead. It was removed from the standard, and is no longer supported at all in Firefox 68 and Chrome 65.
name-
This attribute defines the name of a piece of document-level metadata. It should not be set if one of the attributes
itemprop,http-equivorcharsetis also set.This metadata name is associated with the value contained by the
contentattribute. The possible values for the name attribute are:application-namewhich defines 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.
- Browsers may use this to identify the application. It is different from the
authorwhich defines the name of the document's author.descriptionwhich contains 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.generatorwhich contains the identifier of the software that generated the page.keywordswhich contains words relevant to the page's content separated by commas.referrerwhich controls the HTTPRefererheader attached to requests sent from the document:Values for the contentattribute of<meta name="referrer">no-referrerDo not send a HTTP Refererheader.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">(withdocument.write()orappendChild()) makes the referrer behaviour unpredictable. - When several conflicting policies are defined, the
no-referrerpolicy is applied.
- Dynamically inserting
theme-colorwhich indicates a suggested color that user agents should use to customize the display of the page or of the surrounding user interface. Thecontentattribute 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
contentproperty forcolor-schememay 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 darkis 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-schemeproperty lets individual elements specify their preferred and accepted color schemes. Your styles can adapt to the current color scheme using theprefers-color-schemeCSS media feature.
This attribute may also have a value taken from the extended list defined on WHATWG Wiki MetaExtensions page. Although none have been formally accepted yet, a few commonly used names are:
creatorwhich defines 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 ofrobots, is only followed by Googlebot (the indexing crawler for Google).publisherwhich defines the name of the document's publisher.robotswhich defines 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">Value Description Used 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 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,
noindexwill work, but only after the robot visits the page again. Ensure that therobots.txtfile is not preventing revisits. - Some values are mutually exclusive, like
indexandnoindex, orfollowandnofollow. 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.
slurp, is a synonym ofrobots, but only for Slurp - the crawler for Yahoo Search.viewport, which 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">Value Possible subvalues Description 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.0and10.0Defines the ratio between the device width ( device-widthin portrait mode ordevice-heightin landscape mode) and the viewport size.maximum-scaleA positive number between 0.0and10.0Defines the maximum amount to zoom in. It must be greater or equal to the minimum-scaleor the behaviour is undefined. Browser settings can ignore this rule and iOS10+ ignores it by default.minimum-scaleA positive number between 0.0and10.0Defines the minimum zoom level. It must be smaller or equal to the maximum-scaleor the behaviour is undefined. Browser settings can ignore this rule and iOS10+ ignores it by default.user-scalableyesornoIf set to no, the user is not able to zoom in the webpage. The default isyes. Browser settings can ignore this rule, and iOS10+ ignores it by default.viewport-fitauto,containorcoverThe
autovalue doesn’t affect the initial layout viewport, and the whole web page is viewable.The
containvalue means that the viewport is scaled to fit the largest rectangle inscribed within the display.The
covervalue 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.Specification Status Comment CSS Device Adaptation
The definition of '<meta name="viewport">' in that specification.Working Draft Non-normatively describes the Viewport META element See also:@viewportNotes:- 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.
scheme- This attribute defines the scheme in which metadata is described. A scheme is a context leading to the correct interpretations of the
contentvalue, like a format.Warning: Do not use this value, as it is obsolete. There is no replacement as there was no real usage for it.
Notes
Depending on the attributes set, the kind of metadata can be one of the following:
- If
nameis set, it is document-level metadata, applying to the whole page. - If
http-equivis set, it is a pragma directive — information normally given by the web server about how the web page is served. - If
charsetis set, it is a charset declaration — the character encoding used by the webpage. - If
itempropis set, it is user-defined metadata — transparent for the user-agent as the semantics of the metadata is user-specific.
Examples
<meta charset="utf-8"> <!-- Redirect page after 3 seconds --> <meta http-equiv="refresh" content="3;url=https://www.mozilla.org">
Accessibility concerns
Refreshing content
Pages set with a 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.
- MDN Understanding WCAG, Guideline 2.1 explanations
- MDN Understanding WCAG, Guideline 3.1 explanations
- Understanding Success Criterion 2.2.1 | W3C Understanding WCAG 2.0
- Understanding Success Criterion 2.2.4 | W3C Understanding WCAG 2.0
- Understanding Success Criterion 3.2.5 | W3C Understanding WCAG 2.0
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.
- MDN Understanding WCAG, Guideline 1.4 explanations
- Understanding Success Criterion 1.4.4 | W3C Understanding WCAG 2.0
Specifications
| Specification | Status | Comment |
|---|---|---|
| Referrer Policy The definition of '<meta name="referrer">' in that specification. |
Candidate Recommendation | Defines values and semantics of <meta name="referrer">. |
| HTML Living Standard The definition of '<meta>' in that specification. |
Living Standard | Added itemprop attribute |
| HTML5 The definition of '<meta>' in that specification. |
Recommendation | Added charset attribute |
| HTML 4.01 Specification The definition of '<meta>' in that specification. |
Recommendation |
Browser compatibility
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
meta | Chrome Full support Yes | Edge Full support 12 | Firefox Full support 1 | IE Full support Yes | Opera Full support Yes | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes |
charset | Chrome Full support Yes | Edge Full support 12 | Firefox Full support 1 | IE Full support Yes | Opera Full support Yes | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes |
content | Chrome Full support Yes | Edge Full support 12 | Firefox Full support 1 | IE Full support Yes | Opera Full support Yes | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes |
http-equiv | Chrome Full support Yes | Edge Full support 12 | Firefox Full support 1 | IE Full support Yes | Opera Full support Yes | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes |
name | Chrome Full support Yes | Edge Full support 12 | Firefox Full support 1 | IE Full support Yes | Opera Full support Yes | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes |
Legend
- Full support
- Full support