Skip to main content

<meta>: The metadata element

The <meta> HTML element represents {{Glossary("Metadata","metadata")}} that cannot be represented by other HTML meta-related elements, like {{HTMLElement("base")}}, {{HTMLElement("link")}}, {{HTMLElement("script")}}, {{HTMLElement("style")}} or {{HTMLElement("title")}}.

The type of metadata provided by the <meta> element can be one of the following:

  • If the name attribute is set, the <meta> element provides document-level metadata, applying to the whole page.
  • If the http-equiv attribute is set, the <meta> element is a pragma directive, providing information equivalent to what can be given by a similarly-named HTTP header.
  • If the charset attribute is set, the <meta> element is a charset declaration, giving the character encoding in which the document is encoded.
  • If the itemprop attribute is set, the <meta> element provides user-defined metadata.

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 document's character encoding. If the attribute is present, its value must be an ASCII case-insensitive match for the string "utf-8", because UTF-8 is the only valid encoding for HTML5 documents. <meta> elements which declare a character encoding must be located entirely within the first 1024 bytes of the document.
  • content

    • : This attribute contains the value for the http-equiv or name attribute, depending on which is used.
  • http-equiv

    • : Defines a pragma directive. The attribute's name, short for http-equivalent, is because all the allowed values are names of particular HTTP headers:

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

          Also see {{HTTPHeader("Content-Security-Policy")}}.

      • content-type

        • : Declares the MIME type and the document's character encoding. The content attribute must have the value "text/html; charset=utf-8" if specified. This is equivalent to a <meta> element with the charset attribute specified and carries the same restriction on placement within the document. Note: Can only be used in documents served with a text/html — not in documents served with an XML MIME type.

          Also see {{HTTPHeader("Content-Type")}}.

      • default-style

      • x-ua-compatible

        • : If specified, the content attribute must have the value "IE=edge". User agents are required to ignore this pragma.
      • refresh

  • name

    • : The name and content attributes can be used together 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.

      See standard metadata names for details about the set of standard metadata names defined in the HTML specification.

Examples

<meta charset="utf-8" />

<!-- Redirect page after 3 seconds -->
<meta http-equiv="refresh" content="3;url=https://www.mozilla.org" />

Technical summary

Content categories Metadata content. If the itemprop attribute is present: flow content, phrasing content.
Permitted content None; it is a {{Glossary("void element")}}.
Tag omission Must have a start tag and must not have an end tag.
Permitted parents
  • <meta charset>, <meta http-equiv>: a {{HTMLElement("head")}} element. If the http-equiv is not an encoding declaration, it can also be inside a {{HTMLElement("noscript")}} element, itself inside a <head> element.
  • <meta name>: any element that accepts metadata content.
  • <meta itemprop>: any element that accepts metadata content or flow content.
Implicit ARIA role No corresponding role
Permitted ARIA roles No role permitted
DOM interface {{domxref("HTMLMetaElement")}}

Specifications

Browser compatibility

See also