meta Element

Description

The meta element defines metadata for your document.

You can use this element in different ways, and an HTML document can contain multiple meta elements.

meta element has local Attributes, including name, content, charset, http-equiv.

The charset attribute is new in HTML5.
The HTML4 scheme attribute is now obsolete.

Each instance of the meta element can be used for only one of these purposes.

Name/Value Metadata Pairs

The first use for the meta element is to define metadata in name/value pairs, for which you use the name and content attributes.

The following code uses the meta Element to Define Metadata in Name/Value Pairs.


<!DOCTYPE HTML>
<html>
<head>
    <meta name="author" content="java2s.com"/>
    <meta name="description"  content="A simple example"/>
</head><!--  w w w .  j a va  2 s. co  m-->
<body>
    <a href="http://java2s.com">Visit  java2s.com</a>
</body>
</html>

Click to view the demo

You use the name attribute to specify which type of metadata the element refers to, and the content attribute to provide a value.

The following table lists the predefined metadata types that you can use with the meta element.

Metadata NameDescription
application nameThe name of the web application that the current page is part of
authorThe name of the author of the current page
descriptionA description of the current page
generatorThe name of the software that generated the HTML
keywordsA set of comma-separated strings that describe the content

In addition to the five predefined metadata names, you can also use metadata extensions. Go to http://wiki.whatwg.org/wiki/MetaExtensions to see a list of these extensions.

The robots metadata type is very widely used. It allows the author of an HTML document to specify how the document should be treated by search engines. For example:



<meta name="robots" content="noindex">

The three values that most search engines will recognize are

  • noindex - don't index this page
  • noarchive - don't create archives or cached versions of this page
  • nofollow - don't follow links from this page




















Home »
  HTML CSS »
    HTML »




HTML Introduction
HTML Document
HTML Section
HTML Group Content
HTML Text Marker
HTML Table
HTML Form
HTML Embed