<meta>: The metadata element

Baseline Widely available *

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

* Some parts of this feature may have varying levels of support.

The <meta> HTML element represents metadata that cannot be represented by other meta-related elements, such as <base>, <link>, <script>, <style>, or <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 that applies to the whole page.
  • If the http-equiv attribute is set, the <meta> element acts as a pragma directive to simulate directives that could otherwise be given by an 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 name attribute has a specific meaning for the <meta> element. The itemprop attribute must not be set on a <meta> element that includes a name, http-equiv, or charset attribute.

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. See Content-Security-Policy for more information.

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

default-style

Sets the name of the default CSS style sheet set.

x-ua-compatible

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

refresh

This instruction specifies:

  • The number of seconds until the page should be reloaded - if the content attribute's value is a non-negative integer.
  • The number of seconds until the page should redirect to another - if the content attribute's value is a non-negative integer followed by ;url= and a valid URL.

The timer starts when the page is completely loaded, which is after the load and pageshow events have both fired.

Also see Refresh.

Warning:

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.

media

The media attribute defines which media the theme color defined in the content attribute should be applied to. Its value is a media query, which defaults to all if the attribute is missing. This attribute is only relevant when the element's name attribute is set to theme-color. Otherwise, it has no effect, and should not be included.

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.

Examples

Setting a meta description

The following <meta> tag provides a description as metadata for the web page:

html
<meta
  name="description"
  content="The HTML reference describes all elements and attributes of HTML, including global attributes that apply to all elements." />

Setting a page redirect

The following example uses http-equiv="refresh" to direct the browser to perform a redirect. The content="3;url=https://www.mozilla.org" attribute will redirect page to https://www.mozilla.org after 3 seconds:

html
<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 void element.
Tag omission Must have a start tag and must not have an end tag.
Permitted parents
Implicit ARIA role No corresponding role
Permitted ARIA roles No role permitted
DOM interface HTMLMetaElement

Specifications

Specification
HTML
# the-meta-element

Browser compatibility

See also