DEV Community

G A
G A

Posted on

HTML <meta> Tag

Example

<head>
<meta charset="UTF-8">
<meta name="description" content="Free Web tutorials">
<meta name="keywords" content="HTML, CSS, JavaScript">
<meta name="author" content="John Doe">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>

DEFINITION

A tag in HTML provides metadata about a web page.
A tag is an HTML snippet (SNIPPET refers to a small, reusable piece of source code) placed inside a HTML page's section.
It gives browsers and search engines hidden details about the page.

ATTRIBUTES

charset (character-set)
Specifies the character encoding for the HTML document.
content (text)
Specifies the value associated with the http-equiv or name attribute.
http-equiv (content-type)
Provides an HTTP header for the information/value of the content attribute.
name (author, description, keywords)
Specifies a name for the metadata.

GLOBAL ATTRIBUTES

The tag also supports the Global Attributes in HTML.

SETTING THE VIEWPORT

The viewport is the user's visible area of a web page. It varies with the device - it will be smaller on a mobile phone than on a computer screen.
You should include the following element in all your web pages:
<meta name="viewport" content="width=device-width, initial-scale=1.0">

Examples for Attributes

=> for author - <meta name="author" content="John Doe">
=> for description - <meta name="description" content="Free Web tutorials for HTML and CSS">
=> for keywords(search engines) - <meta name="keywords" content="HTML, CSS, JavaScript">

References
https://www.w3schools.com
https://www.geeksforgeeks.org

Top comments (0)