Meta tag details

Source: Internet
Author: User
Tags sorts


Meta is an auxiliary tag in the head area of the HTML language. In almost all webpages, we can see the following HTML code:

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

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.

I. Composition of meta tags

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

1. Name 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, entertaiment, human">

B. Description (website content description)

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

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, [email protected]">

2. 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 meat 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 =">

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">

Ii. meta tag Functions

We have introduced some basic components of meta tags. Next let's take a look at the common features of Meta Tags:

1. Help the home page to be logged on by various search engines

A very important function of meta tags is to set keywords to help you log on to your homepage by various search engines and increase website access volume. In this function, the most important thing is to set the keywords and description. According to the working principle of the search engine, the search engine first sends a robot to automatically search for the keywords and decription on the page, adds them to its own database, and then sorts the Website Based on the keyword density. Therefore, we must set keywords to improve the page's click-through rate. Here is an example for your reference:

<Meta name = "keywords" content = "politics, economy, technology, culture, health, emotion, soul, entertainment, life, society, enterprise, transportation">
<Meta name = "Description" content = "politics, economy, technology, culture, health, emotion, soul, entertainment, life, society, enterprise, transportation">

After these keywords are set, the search engine automatically adds these keywords to the database and sorts them according to their density.

2. Define the language of the page

This is the most common function of meta tags. When creating a webpage, we can see it in pure HTML code. Its function is to define the language of your webpage, when a visitor accesses your webpage, the browser will automatically identify and set the language in the webpage. If your webpage is configured with a GB code, and the browser does not install a GB code, in this case, the web page only displays the default browser language set by the viewer. Similarly, if the webpage is in English, charset = en. The following is a representative example:

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

This Code indicates that the web page language is set as a country code.

3. Automatically refresh and refer to the new page

If you want your webpage to automatically access the specified webpage within the specified time, you can use the meta tag to automatically refresh the webpage. Let's take a look at the code below:

& Lt; Meta http-equiv = & lt; refresh & gt; content = & lt; url = & gt ″〉

This code can make a current page automatically go to The page after 2 seconds, this is the role of Meta Refresh, in the content, 2 indicates the set time (in seconds), and the URL is the webpage address automatically connected after the specified time.

4. Implement the animation effect during webpage Conversion

Using meta tags, we can also achieve the animation effect as soon as we enter or exit the webpage, you only need to add the following code between the

<Meta http-equiv = "Page-Enter" content = "revealtrans (duration = 5.0, transition = 20)">
<Meta http-equiv = "Page-Exit" content = "revealtrans (duration= 5.0, transition = 20)">

Once the above Code is added to a webpage, we will see some special effects when entering and leaving the page. This function is actually the same as format/Page Transition in frontpage2000, however, we should note that the webpage to be added cannot be a frame page;

5. webpage Rating Evaluation

Browsers of ie4.0 and later versions can prevent restricted websites from being browsed. The reason why browsers automatically identify restricted websites is that, this is because the level of the website has been set in the meta tag of the website, and this level is assessed by the us rsac, that is, the entertainment board's rating agency, if you need to comment on your website, you can connect to the website renewal. The following is an example of code:

<Meta http-equiv = "pics-label ″
Content = '(PICS-1.1 " ″
L Gen true comment "rsaci North America server ″
For ″
On "2001.08.16t08: 15-0500 ″
R (N 0 s 0 V 0 l 0) '> ))′〉

6. Control page Buffering

The meta tag can be used to set the expiration time of a webpage. That is to say, when you set the browser to browse a webpage in Internet Explorer, first view the page in the local buffer. Then, when you browse a webpage, sometimes, the browser will automatically browse the pages in the buffer until the time set in Meta expires. At this time, the browser will get a new page. For example, the following code indicates that the webpage expires at, January 1, January 12, 2001.

<Meta http-equiv = "expires" content = "Friday, 12-Jan-2001 18:18:18 GMT"> ″〉

7. Control the webpage display window

You can also use the meta tag to control the window displayed on the webpage. You only need to add the following code to the webpage: <metahttp-equiv = "window-target" content = "_ top"> This code prevents web pages from being called as a frame.


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: 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.