Detailed description of meta tags in HTML

Source: Internet
Author: User

<Meta> elements provide meta-information about pages, such as descriptions and keywords for search engines and update frequency. <Meta> the tag is in the document header and does not contain any content. <Meta> the tag attribute defines the name/value pairs associated with the document.
Meta is an auxiliary tag in the head area of the html language. In almost all webpages, we can see the following html code:

<Head>

<Meta http-equiv = "content-Type" content = "text/html; charset = gb2312"/>

</Head>

Maybe you think the code is dispensable. In fact, if you can use the meta tag well, it will bring unexpected results, for example, adding keywords will be automatically collected by large search sites; you can set the page format and refresh, etc. Meta tag Composition

Meta tags have two attributes: http-equiv and name. different attributes have different parameter values, which enable different webpage functions.

CommonName attribute

The name attribute is mainly used to describe the webpage, and the corresponding attribute value is content. The content in the content is mainly used to facilitate search engine robots to find information and classify information.

The syntax format of the name attribute of the meta tag is <meta name = "parameter" content = "specific parameter value">.

The name attribute has the following parameters:

A. Keywords)

Note: keywords are used to tell the search engine what keywords are on your webpage.

Example: <meta name = "keywords" content = "science, education, culture, politics, ecnomics, relationships, entertainment, human">

B. description (website content description)

Description: description is used to tell the search engine the main content of your website.

Key points for designing the website description:

① The webpage is described as a natural language rather than a listing of keywords (opposite to the keywords design );

② Describe the core content of a webpage as accurately as possible, usually the summary information of the webpage content, that is, the abstract information that the search engine wants to display in the search results;

③ The webpage description contains valid keywords;

④ The webpage description content is highly correlated with the webpage title content;

⑤ The webpage description content is highly correlated with the webpage subject content;

⑥ There is not much text to describe on the web page. Generally, it does not exceed the maximum number of words in the abstract information of the search engine's search results (generally within 100 Chinese characters, there are slight differences between different search engines ).

Example: <meta name = "description" content = "This page is about the meaning of science, education, culture.">

C. robots (robot wizard)

Note: robots is used to tell robots which pages need to be indexed and which pages do not need to be indexed.

Content parameters include all, none, index, noindex, follow, and nofollow. The default value is all.

Example: <meta name = "robots" content = "none">

D. author (author)

Note: the author of the webpage

Example: <meta name = "author" content = "root, root@21cn.com">

Required http-equiv attributes

Http-equiv, as its name implies, is equivalent to an http File Header. It can return some useful information to the browser to help display the webpage content correctly and accurately. The corresponding attribute value is content, content is actually the variable value of each parameter.

The syntax of the http-equiv attribute of the meta tag is as follows: <meta http-equiv = "parameter" content = "parameter variable value">. The http-equiv attribute mainly includes the following parameters:

A. Expires (TERM)

Note: You can set the expiration time of a webpage. Once the webpage expires, it must be re-transmitted to the server.

Usage: <meta http-equiv = "expires" content = "Fri, 12 Jan 2001 18:18:18 GMT">

Note: The GMT time format must be used.

B. Pragma (cache Mode)

Note: The browser is prohibited from accessing the page content from the cache of the local computer.

Usage: <meta http-equiv = "Pragma" content = "no-cache">

Note: in this way, visitors will not be able to browse offline.

C. Refresh (Refresh)

Note: automatically refresh and point to the new page.

Usage: <meta http-equiv = "Refresh" content = "2; URL = http://www.root.net">)

Note: 2 means that the URL is automatically refreshed after 2 seconds.

D. Set-Cookie (cookie setting)

Note: If the webpage expires, the cookie on the disk will be deleted.

Usage: <meta http-equiv = "Set-Cookie" content = "cookievalue = xxx; expires = Friday, 12-Jan-2001 18:18:18 GMT; path =/">

Note: The GMT time format must be used.

E. Window-target (display Window settings)

Note: The Force page is displayed on an independent page in the current window.

Usage: <meta http-equiv = "Window-target" content = "_ top">

Note: It is used to prevent others from calling their own pages in the framework.

F. content-Type (display character set setting)

Description: sets the character set used on the page.

Usage: <meta http-equiv = "content-Type" content = "text/html; charset = gb2312">

G. content-Language (set the Display Language)

Usage: <meta http-equiv = "Content-Language" content = "zh-cn"/>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.