<meta>
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. (如果定义了名称或http-equiv属性,则必须定义内容属性。如果未定义这些属性,则也不能定义内容属性。)
Syntax
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
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. | |
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.