<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 representsmetadata 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
nameattribute is set, the<meta>element providesdocument-level metadata that applies to the whole page. - If the
http-equivattribute is set, the<meta>element acts as apragma directive to simulate directives that could otherwise be given by an HTTP header. - If the
charsetattribute is set, the<meta>element is acharset declaration, giving the character encoding in which the document is encoded. - If the
itempropattribute is set, the<meta>element providesuser-defined metadata.
In this article
Attributes
This element includes theglobal attributes.
Note:Thename attribute has a specific meaning for the<meta> element.Theitemprop attribute must not be set on a<meta> element that includes aname,http-equiv, orcharset attribute.
charsetThis 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.contentThis attribute contains the value for the
http-equivornameattribute, depending on which is used.http-equivDefines a pragma directive, which are instructions for the browser for processing the document.The attribute's name is short for
http-equivalentbecause the allowed values are names of equivalent HTTP headers.mediaThe
mediaattribute defines which media the theme color defined in thecontentattribute should be applied to.Its value is amedia query, which defaults toallif the attribute is missing.This attribute is only relevant when the element'snameattribute is set totheme-color.Otherwise, it has no effect, and should not be included.nameThe
nameandcontentattributes can be used together to provide document metadata in terms of name-value pairs, with thenameattribute giving the metadata name, and thecontentattribute giving the value.
Examples
>Setting a meta description
The following<meta> tag provides adescription as metadata for the web page:
<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 useshttp-equiv="refresh" to direct the browser to perform a redirect.Thecontent="3;url=https://www.mozilla.org" attribute will redirect page tohttps://www.mozilla.org after 3 seconds:
<meta http-equiv="refresh" content="3;url=https://www.mozilla.org" />Technical summary
| Content categories | Metadata content. If theitemprop attribute is present:flow content,phrasing content. |
|---|---|
| Permitted content | None; it is avoid 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 | Norole permitted |
| DOM interface | HTMLMetaElement |
Specifications
| Specification |
|---|
| HTML> # the-meta-element> |