HTML <meta> tag

The word meta means about. With the <meta> tag you are providing information about data, or metadata. Specifically, information (things like a description, keywords, and author) about a particular form of data (a web document). This information can be used by search engines when they index your site. The <meta> tag can also be used to refresh a page, set the page's content type, and set when the page expires.

Metadata is not seen on a page but works behind the scenes.

NOTE: The <meta> tag has no end tag.

NOTE: The <meta> tag always goes in the head section of an HTML document.

Attributes

Attribute Description Possible values
content Required. Sets a value regarding some aspect of a webpage as specified by the name attribute. Example: You gave the name attribute the value "author", so the value you give to this attribute would be the name of the person who made the page contentValue
http-equiv Specifies HTTP header information regarding the value set for the content attribute. Uses include refreshing a page, setting the page's content type, setting when a page expires, and more. content-type, expires, last-modified, refresh, set-cookie
name Specifies what aspect of a webpage you are describing author, description, generator, keywords, revised
scheme Specifies the scheme to use to interpret the value set for the content attribute theScheme

Standard attributes

dir, lang, xml:lang

For more information on standard attributes, check out our HTML standard attributes reference page.

Event attributes

NONE

For more information on event attributes, check out our HTML event attributes reference page.

Examples

Specifying what program was used to create a page:

<meta name="generator" content="Notepad++" />

Specifying the author of a page:

<meta name="author" content="John Abigail" />

Offering a description of a page:

<meta name="description" content="Computer hardware at discount prices. We have motherboards, memory chips, network adapters, hard drives, and much more." />

Offering page keywords:

<meta name="keywords" content="computer hardware, computer parts, motherboards, memory chips, network adapters, hard drives" />

Reloading the current page every five seconds:

<meta http-equiv="refresh" content="5" />

Setting the http-equiv attribute to "refresh", you can then specify how often to reload the page (in seconds) with the content attribute.

Page refreshing is common for time sensitive information such as currency pricing (as seen on the website www.xe.com which refreshes the homepage once every 60 seconds), news, and stocks.

Tips & notes

The <meta> tag's attributes work together - the value you assign to the content attribute depends on the value you assign to either the name or http-equiv attributes.

Remember to always use the content attribute. Without it, the <meta> tag will not have data to associate with the name or http-equiv attributes. The <meta> tag needs to have a name/value pair.

Web Reference
  1. CSS reference
  2. RSS reference
  3. HTML reference


© Copyright 2011-2012 Landofcode.com
Terms of use | Privacy policy | Copyright information | Make a donation