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 global 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
- Declares the page's character encoding. This attribute 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 harmless content as HTML. This happens with at least
JIS_C6226-1983
,JIS_X0212-1990
,HZ-GB-2312
,JOHAB
, the ISO-2022 family, and the EBCDIC family. (ASCII-incompatible encodings are those that don't map the 8-bit code points0x20
to0x7E
to the0x0020
to0x007E
Unicode code points) - Authors must not use
CESU-8
,UTF-7
,BOCU-1
andSCSU
, because cross-site scripting attacks with these encodings have been demonstrated. - Authors should not use
UTF-32
because 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-Type
header 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-7
fallback cross-scripting technique. - The
<meta>
element with acharset
attribute is a synonym for the pre-HTML5<meta http-equiv="Content-Type" content="text/html; charset=IANAcharset">
, whereIANAcharset
contains the value of the equivalentcharset
attribute. This syntax is still allowed, although no longer recommended.
- Authors are encouraged to use
content
- This attribute contains the value for the
http-equiv
orname
attribute, depending on which was used. http-equiv
- This attribute can contain the name of an HTTP header, hence the attribute name http-equivalent. It defines an instruction that can alter server and user-agent behavior. The value of the instruction is defined inside the
content
attribute, and can be one of the following:"content-language"
- Defines the default language of the page. It can be overridden by the lang attribute on any element.
Do not use this value, as it is obsolete. Prefer the
lang
attribute 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 helps 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 HTTP
content-type
entity-header field, but as it is inside an HTML page, most values other thantext/html
are impossible. Therefore the valid syntax for itscontent
is the string 'text/html
' followed by a character set with the following syntax: '; charset=IANAcharset
', whereIANAcharset
is the preferred MIME name for a character set as defined by the IANA. "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.
Note: Do not use this instruction, as it is obsolete. Use the HTTP header
Set-Cookie
instead.
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-equiv
orcharset
is also set.This metadata name is associated with the value contained by the
content
attribute. The possible values for the name attribute are:application-name
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
author
defines the name of the document's author.description
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.generator
contains the identifier of the software that generated the page.keywords
contains words relevant to the page's content, separated by commas.referrer
controls theReferer
HTTP header attached to requests sent from the document:Values for the content
attribute of<meta name="referrer">
no-referrer
Do not send a HTTP Referer
header.origin
Send the origin of the document. no-referrer-when-downgrade
Send the origin as referrer to URLs as secure as the current page, (https→https), but don't send a referrer to less secure URLs (https→http). This is the default behavior. origin-when-crossorigin
Send the full URL (stripped of parameters) for same-origin requests, but only send the origin for other cases. unsafe-URL
Send the full URL (stripped of parameters) for same-origin or cross-origin requests. - Some browsers support the deprecated values
always
,default
, andnever
for referrer. - Dynamically inserting
<meta name="referrer">
(withdocument.write
orappendChild
) makes referrer behavior unpredictable. - When several conflicting policies are defined, the no-referrer policy is applied.
- Some browsers support the deprecated values
The 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:
Finally, a few names are in common use, though not in the process of being standardized:
creator
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
, but is only followed by Googlebot, the indexing crawler for Google.publisher
defines the name of the document's publisher.robots
defines the behavior 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 index
Allows the robot to index the page (default). All noindex
Requests the robot to not index the page. All follow
Allows the robot to follow the links on the page (default). All nofollow
Requests the robot to not follow the links on the page. All none
Equivalent to noindex, nofollow
Google noodp
Prevents using the Open Directory Project description, if any, as the page description in search engine results. noarchive
Requests the search engine not 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 appear as the referring page of an indexed image. Google nocache
Synonym 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 therobots.txt
file doesn't preventing revisits. Some search engines have developer's tools, allowing quick removal of pages. - Some values are mutually exclusive, like
index
andnoindex
, orfollow
andnofollow
. In these cases the robot's behavior is undefined and may vary between them. - Some crawler robots, like Google, Yahoo, and Bing, support the same values for the HTTP header
X-Robot-Tags
; this allows non-HTML documents like images to use these rules.
slurp
, 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 width
A positive integer number, or the text device-width
Defines the pixel width of the viewport, or allows the viewport to adapt to the device's screen width. 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
and10.0
Defines the ratio between the device width ( device-width
in portrait mode ordevice-height
in landscape mode) and the viewport size.maximum-scale
A positive number between 0.0
and10.0
Defines the maximum amount to zoom in. It must be greater or equal to the minimum-scale
or the behavior is undefined. Browser settings can ignore this rule, and iOS10+ ignores it by default.minimum-scale
A positive number between 0.0
and10.0
Defines the minimum zoom level. It must be smaller or equal to the maximum-scale
or the behavior is undefined. Browser settings can ignore this rule, and iOS10+ ignores it by default.user-scalable
yes
orno
If 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.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:@viewport
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.
scheme
- This attribute defines the scheme in which metadata is described. A scheme is a context leading to the correct interpretations of the
content
value, like a format.Notes: 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
name
is set, it is document-level metadata, applying to the whole page. - If
http-equiv
is set, it is a pragma directive — information normally given by the web server about how the web page is served. - If
charset
is set, it is a charset declaration — the character encoding used by the webpage. - If
itemprop
is 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">
Specifications
Specification | Status | Comment |
---|---|---|
Referrer Policy The definition of '<meta name="referrer">' in that specification. |
Editor's Draft | 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
Feature | Chrome | Edge | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|---|
Basic support | (Yes) | (Yes) | 1.0 (1.7 or earlier) | (Yes) | (Yes) | (Yes) |
name="referrer" |
17 | No support | 36.0 (36.0) [1] | ? | ? | ? |
Constrained to values listed under referrer (as specified in the spec.) | 46.0 | No support |
Feature | Android | Android Webview | Edge | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile | Chrome for Android |
---|---|---|---|---|---|---|---|---|
Basic support | (Yes) | (Yes) | (Yes) | 1.0 (1.0) | (Yes) | (Yes) | (Yes) | (Yes) |
name="referrer" |
? | (Yes) | No support | 36.0 (36.0) [1] | ? | ? | ? | (Yes) |
Constrained to values listed under referrer (as specified in the spec.) | No support | 46.0 | No support | ? | ? | ? | ? | 46.0 |
[1] The referrer
value wasn't taken into account when navigation was happening via the context menu or middle click until Firefox 39.