Description
The HTML element <meta>
is used to define metadata about an HTML document.
Metadata is data (or information) about data, which includes character set, author, page description, keywords, viewport settings, etc.,
Metadata is not displayed on the browsers as it is not part of visible content, but it is machine-readable.
- It is used by browsers to determine how to display the content or when to reload a page automatically
- It is used by search engines for website SEO
This tag must appear only within the <head>
element.
The below table summarizes its usage.
Usage Details | |
Placement | It must be defined within the <head> element. |
Contents | None. It is an empty element. |
Tags | Only the opening tag is required. |
Versions | HTML 2, 3.2, 4, 4.01, 5 |
Syntax
Here is the basic syntax of the <meta>
element.
<meta name="text" content="text">
Examples
<!DOCTYPE html>
<html lang="en">
<head>
<title>Example - HTML Element meta</title>
<meta charset="UTF-8">
<meta name="author" content="Arun Kumar">
<meta name="description" content="Free Online Tutorials">
<meta name="keywords" content="Random Codez Tutorials,HTML,CSS,JavaScript">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<p>Meta tag is used to define data (or information) about data and its contents are not displayed on browsers.<p>
</body>
</html>
Attributes
The following table shows the list of supported and unsupported attributes for the <meta>
element.
Attribute Type | Details |
Element-Specific Attributes | The tag <meta> has some element-specific attributes listed in the below table. |
Global Attributes | Like all other HTML tags, the tag <meta> supports the HTML Global Attributes. |
Event Attributes | The tag <meta> also supports the HTML Event Attributes. |
Here is a list of attributes that are specific to the <meta>
element.
- One of the required attributes must be specified for the meta element to be valid.
Attribute | Value | Required | Description |
name |
application-name, author, description, generator, keywords |
Yes | Defines a name for the meta-information contained in the content attribute. |
content |
text | Yes | Gives the value associated with the http-equiv or name attribute. This attribute must be specified if either http-equiv or name attribute is present. |
charset |
character-set | Yes | Specifies the character encoding for the HTML document. |
http-equiv |
content-type, default-style, refresh |
Yes | Binds the meta-information in the content attribute to an HTTP response header. |
high |
number | Yes | Specifies the range that is considered to be a high value. |
scheme |
format/URI | No | Obsolete Specifies a scheme to be used to interpret the value of the content attribute. |
Browser Compatibility
The tag <meta>
is supported in all modern browsers.
- Google Chrome 1+
- Internet Explorer or Edge 2+
- Firefox 1+
- Apple Safari 1+
- Opera 4+