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 Name | Description |
---|---|
application name | The name of the web application |
author | The name of the author |
description | A description of the page |
generator | The name of the software that generated the HTML |
keywords | A 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">
<meta> |
Yes | Yes | Yes | Yes | Yes |
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 | 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 |
The <meta> tag supports the Global Attributes in HTML.
None.
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>
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 Value | Description |
---|---|
refresh | ]]> |
default-style | specifies 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>