HTML <meta>
Tag
The tag is an important HTML tag that provides metadata about the document. Metadata includes information such as character set, author, description, and keywords. This information helps search engines, browsers, and other web services understand and index the page properly.
How to Use the <meta>
Tag
The <meta>
tag is a self-closing tag that goes inside the <head>
section of an HTML document. It does not have a closing tag. Here is an example of how to use the <meta>
tag to specify the character set of the document:
<meta charset="UTF-8">
In this example, the charset
attribute specifies that the character encoding of the document is UTF-8.
Main Attributes of the <meta>
Tag
Attribute | Description |
---|---|
charset | Specifies the character encoding of the document |
name | Specifies the name of the metadata |
content | Specifies the value of the metadata |
http-equiv | Provides an HTTP header for the information/value of the content attribute |
Here is an example of how to use the <meta>
tag with the name
and content
attributes to specify the author of the document:
<meta name="author" content="John Doe">
In this example, the name
attribute specifies that the metadata is the author of the document, and the content
attribute specifies the value of the author's name, which is "John Doe".
Another common use of the <meta>
tag is to specify the description of the document for search engines. Here is an example:
<meta name="description" content="This is a tutorial on HTML meta tags">
In this example, the name
attribute specifies that the metadata is the description of the document, and the content
attribute specifies the actual description text.
Conclusion
The <meta>
tag is a crucial element in HTML that provides important metadata about a document. By using the <meta>
tag effectively, you can improve the visibility and indexing of your web pages on search engines.