HTML Tag Reference - HTML tag <meta>








The <meta> element includes additional HTTP header information about the document. This element is placed in the <head> section of the document.

The name attribute specifies which metadata type. The content attribute to provide a value.

The following table lists the predefined metadata types:

Metadata NameDescription
application nameThe name of the web application
authorThe name of the author
descriptionA description of the page
generatorThe name of the software that generated the HTML
keywordsA set of comma-separated strings that describe the content of the page
<meta name="author" content="your Name">
<meta name="description" content="books.">      
<meta name="generator" content="Hand">
<meta name="keywords" content="art, oils, landscape">




Browser compatibility

<meta> Yes Yes Yes Yes Yes

What's new in HTML5

The scheme attribute is not supported in HTML5.

HTML5 has a new attribute, charset.

For HTML 4.01:

<meta http-equiv="content-type" content="text/html; charset=UTF-8">

For HTML5:

<meta charset="UTF-8">

Attribute

Attribute Value Description
charset character_set Set the character encoding for the HTML document
content text Set the value associated with the http-equiv or name attribute
http-equiv content-type
default-style
refresh
Set an HTTP header for the content attribute
name application-name
author
description
generator
keywords
Specifies a name for the metadata
scheme format/URI Not supported in HTML5.
Set a scheme to interpret the value of the content attribute




Global Attributes

The <meta> tag supports the Global Attributes in HTML.

Default CSS Settings

None.

Example

The following code specifies name/value metadata pairs.

<!DOCTYPE HTML>
<html>
<head>
    <meta name="author" content="java2s.com"/>
    <meta name="description" content="A simple example"/>
</head><!--from ww w.  j av a2 s.c  o  m-->
<body>
      <a href="http://java2s.com">Visit java2s.com</a>
</body>
</html>

Click to view the demo

Simulate an HTTP Header

The meta element can override the value of one of the HTTP (Hypertext Transfer Protocol) headers. The http-equiv attribute specifies which header you want to simulate. The content attribute provides the value.

There are three permitted values for the http-equiv attribute:

Attribute ValueDescription
refresh ]]>
default-stylespecifies the preferred stylesheet. The value of the content attribute must match the title attribute on a script or link element in the same page.
content-type ]]>
<meta http-equiv="content-type" content="text/html; charset=ISO646-US">
<meta http-equiv="default-style" content="stylesheet">
<meta http-equiv="refresh" content="3">
<meta http-equiv="refresh" content="3;url=http://www.java2s.com">

The following code specifies to the refresh(reload) the page every five seconds.

<!DOCTYPE HTML>
<html>
<head>
    <meta http-equiv="refresh" content="5" />
</head><!--from  w  w  w  .j  a va 2  s  . c  om-->
<body>
      <a href="http://java2s.com">Visit java2s.com</a>

</body>
</html>

Click to view the demo