HTML meta tags provide metadata about an HTML document. Metadata will not be displayed on the page but will be used by browsers, search engines, and other web services.
The meta tag can contain various attributes to define the metadata for the HTML document. Below are some common attributes:
Meta tags should be placed within the <head> section of the HTML document.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Html Tutorial</title>
</head>
<body>
<h1>Hello world!</h1>
</body>
</html>
Attribute | Description | Example |
---|---|---|
name | Specifies the name of the metadata. Common values include description, keywords, and author. |
Try yourself
|
content | Provides the value associated with the name or http-equiv attribute. |
Try yourself
|
http-equiv | Provides an HTTP header for the information/value of the content attribute. Common values include content-type and refresh. |
Try yourself
|
charset | Specifies the character encoding for the HTML document. |
Try yourself
|
viewport | Controls the layout on mobile browsers. It is used to set the width and scaling of the viewport. |
Try yourself
|
Here are some examples of commonly used meta tags in HTML documents:
Example: Description Meta Tag
<meta name="description" content="Learn about HTML Meta Tags, their attributes, and how they are used to provide metadata about an HTML document.">
This example provides a brief description of the webpage's content, which can be used by search engines.
<meta name="keywords" content="HTML, Meta Tags, Metadata, HTML Tutorial">
This example provides a list of keywords relevant to the content of the webpage, which can be used by search engines.
<meta name="author" content="John Doe">
This example specifies the author of the HTML document.
<meta charset="UTF-8">
This example specifies the character encoding for the HTML document.
<meta name="viewport" content="width=device-width, initial-scale=1.0">
This example sets the width and initial scale of the viewport, making it responsive on mobile devices.
Here are some important notes and best practices when using the meta tags: