HTML <meta> Tag

The <meta> tag contains metadata, which specifies page description, keywords, author of the document, etc. The 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 it.

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

You must define the content attribute if the name or the http-equiv attributes are defined. If these attributes are not defined, the content attribute cannot be defined either.

Syntax

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

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

Define the keyword for the search engines:

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

Define the website description:

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

Define the author of the page:

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

Refresh the document every one minute (60 seconds):

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

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

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

Attributes

Attribute Value Description
charset character_set Defines the encoding of the document.
content text Defines the value of the name or http-equiv attributes, depending on context.
http-equiv Defines a hypertext header (simulates the HTTP header) and determines its processing. When the page is displayed, the browser will follow the instructions given in the attribute.
content-type Indicates the type of document encoding.
default-style Indicates preferred style to use on the page. (Must contain the id of the <link> element, which refers to a CSS style sheet, or the identifier of the <style> element that contains the style sheet).
refresh Defines the time in seconds before the page is reloaded or the time before the redirection to another page, if "url = page_name" is specified after the time is specified.
name Defines the name for meta tag. If this attribute is omitted, it is considered equivalent to the attribute http-equiv. Not used when there are http-equiv or charset attributes.
application-name Defines a name for the web application used on the page.
author Indicates the name for the web page’s author.
description Contains description of the web page for search engines.
generator Indicates the software used to create the page (for non-handwritten pages).
keywords Contains keywords.
scheme format/url Contains information about the scheme or the name of the scheme itself, which should be used to clarify the value of the content attribute property.
Not supported in HTML5.

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

Browser support

chrome edge firefox safari opera

Practice Your Knowledge

What is the purpose of a meta tag in HTML?

Quiz Time: Test Your Skills!

Ready to challenge what you've learned? Dive into our interactive quizzes for a deeper understanding and a fun way to reinforce your knowledge.

Do you find this helpful?