<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 (属性)

AttributeValueDescription
charsetcharacter_setDefines the encoding of the document.
contenttextDefines the value of the name or http-equiv attributes, depending on context.
http-equivDefines 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-typeIndicates the type of document encoding.
refreshDefines 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.
nameDefines 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-nameDefines a name for the web application used on the page.
authorIndicates the name for the web page’s author.
descriptionContains description of the web page for search engines.
generatorIndicates the software used to create the page (for non-handwritten pages).
keywordsContains keywords.
schemeformat/urlContains 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.



请遵守《互联网环境法规》文明发言,欢迎讨论问题
扫码反馈

扫一扫,反馈当前页面

咨询反馈
扫码关注
返回顶部