It is used to represent metadata (data that describes data) of the HTML document. This data cannot be represented using other similar elements such as
<title>, and therefore we will use
It always goes inside
<head> and is usually used to specify the encoding of the document, give a description to the page, indicate author and keywords, define the viewport, etc.
It can contain the following types of metadata:
- If the
nameattribute is specified, the
<meta>element provides metadata for the entire document, applicable to the entire page.
- If the
http-equivattribute is specified, the
<meta>element is a pragma directive, providing information equivalent to what a similarly named HTTP header can provide.
- If the
charsetattribute is specified, the
<meta>element is a character set declaration, which provides the character encoding of the document.
- If the
itempropattribute is specified, the
<meta>element provides user-defined metadata.
<meta> elements are not displayed on the page but are machine-readable. They are used by browsers, search engines, and other web services.
It can have several attributes:
charset: used to declare the character encoding of the document. If present, its value must be a case-insensitive ASCII match of the
utf-8string, since UTF-8 is the only valid encoding for HTML5 documents.
<meta>elements with this attribute must be completely within the first 1024 bytes of the document.
content: contains the value for the
nameattribute, it depends on which one is declared in that
- http-equiv: defines a pragma directive. The attribute is called
http-equiv(alent)because all the values it can take are names of specific HTTP headers.
content-security-policy: allows you to define a content policy for the page. Content policies specify about all server sources and endpoints that help protect against scripted attacks.
content-type: declares the MIME type and character encoding of the document. If specified, the content attribute must have the value
text/html; charset=utf-8, which is the equivalent of a
<meta>element with the specified charset attribute and carries the same location restriction within the document. It can only be used in documents served as
text/html, not those served with a MIME type XML.
default-style: specifies the name of the default CSS.
x-ua-compatible: if specified, the content attribute must have the value
IE=edge. User agents must ignore this directive.
refresh: this statement specifies the number of seconds until the page is reloaded (if the
contentattribute contains a positive integer) or the number of seconds until the page is redirected to another (if the
contentattribute contains a positive integer followed by
;url=string and a valid URL). Users using assistive technologies such as a screen reader may be unable to read and understand the content of the page before being automatically redirected if the specified time is too short. The sudden and unannounced reload of the page can also disorient people with some form of visual impairment.
contentattributes can be used together to provide metadata in the form of name-value pairs, with the
nameattribute specifying the name of the metadata and the
contentattribute doing the same for the value. There is a list of standard metadata names defined in the HTML specification.
itemprop attribute must not be specified on the same
<meta> element that already has a
charset attribute defined.
- Type: -
- Self-closing: No
- Semantic value: No