W3docs

HTML <meta> Tag

The <meta> tag is used to define the metadata, which inform the browser and search engines about HTML document. Tag description, attributes and using examples.

The <meta> tag contains metadata, which specifies the page description, keywords, author of the document, etc. Metadata is used by browsers, search engines, and other web services, and isn’t displayed on the web page. A web document can contain more than one <meta> tag, but generally, the physical appearance of the document is not affected by them.

The <meta> tag is placed in the <head> element.

You must define the content attribute if the name or http-equiv attributes are used. The content attribute is not used with the charset attribute.

Syntax

The <meta> tag is empty, which means that the closing tag isn’t required. However, in XHTML, the <meta> tag must be self-closed (<meta />).

The usage of the <meta> tag with its different values

Define the keyword for the search engines:

HTML <meta> Tag

<meta name="keywords" content="HTML, CSS, XML, XHTML, JavaScript">

Define the website description:

HTML <meta> Tag

<meta name="description" content="Tutorials on HTML, CSS and PHP">

Define the author of the page:

HTML <meta> Tag

<meta name="author" content="myauthor">

Refresh the document every one minute (60 seconds):

HTML <meta> Tag

<meta http-equiv="refresh" content="60">

Set the viewport to make the website look good on all devices:

HTML <meta> Tag

<meta name="viewport" content="width=device-width, initial-scale=1.0">

Attributes

AttributeValueDescription
charsetcharacter_setDefines the character encoding of the document.
contenttextDefines the value of the name or http-equiv attributes.
http-equivcontent-type, default-style, refreshDefines a hypertext header (simulates the HTTP header) and determines its processing.
nameapplication-name, author, description, generator, keywords, schemeDefines the name for the meta tag.

The <meta> tag also supports the Global Attributes and the Event Attributes.

Practice

Practice

What is the purpose of a meta tag in HTML?