Meta attributes in HTML are reproduced in the blog from hero_213

Source: Internet
Author: User
Tags sorts

meta attributes in HTMLMeta is an accessible tag in the head area of the HTML language. In almost all pages, we can see HTML code similar to the following:

<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">

Maybe you think the code is dispensable. In fact, if you can use good meta tags, will bring you unexpected results, such as keywords will be automatically collected by large search sites automatically, you can set the page format and refresh and so on.


I. Composition of META tags

Meta tags have a total of two properties, which are the Http-equiv property and the Name property, and different properties have different parameter values, these different parameter values to achieve a different page function.

1. Name property

The name attribute is mainly used to describe the Web page, and its corresponding property value is content,content content is mainly convenient for search engine robot to find information and classification information.

The syntax format for the Name property of the meat tag is: <meta name= "parameter" content= "specific parameter value".

Where the name attribute mainly has the following parameters:

A, Keywords (keywords)

Description: Keywords is used to tell search engines what keywords are on your page.

Example: <meta name = "keywords" content= "science, Education,culture,politics,ecnomics,relationships, Entertaiment, Human ">

B, description (Website content description)

Description: Description is used to tell search engines 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)

Description: Robots is used to tell the search robot which pages need to be indexed and which pages do not.

The content parameters are all,none,index,noindex,follow,nofollow. The default is all.

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

D, author (author)

Description: The author of the callout page

Example: <meta name= "author" content= "Lightning, [email protected]" >

2. HTTP-EQUIV Properties

Http-equiv, as the name implies, is equivalent to the HTTP file header function, it can send back some useful information to the browser to help correct and accurate display of the content of the Web page, and the corresponding property value of content,content content is actually the variable value of each parameter.

The Http-equiv property syntax format for the meat tag is: <meta http-equiv= "parameter" content= "parameter variable value", where the Http-equiv attribute mainly has the following parameters:

A, Expires (term)

Description: Can be used to set the expiration time of a Web page. Once the page expires, it must be retransmitted to the server.

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

Note: The time format of GMT must be used.

B, Pragma (cache mode)

Description: Prevents the browser from accessing page content from the local computer's cache.

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

Note: This setting makes it impossible for visitors to browse offline.

C, refresh (refreshed)

Description: Automatically refreshes and points to the new page.

Usage: <meta http-equiv= "Refresh" content= "2;url=http://www.webjx.com" >

Note: 2 of these are meant to be automatically refreshed to URL URLs after 2 seconds of stay.

D, Set-cookie (Cookie setting)

Note: If the page expires, the cookie will be deleted.

Usage: <meta http-equiv= "Set-cookie" content= "COOKIEVALUE=XXX; Expires=friday, 12-jan-2001 18:18:18 GMT; path=/">

Note: The time format of GMT must be used.

E, Window-target (display window settings)

Description: Forces the page to appear on a separate page in the current window.

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

Note: Used to prevent others from calling their own pages in the frame.

F, Content-type (setting of the display character set)

Description: Sets the character set used by the page.

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

Second, the function of meta tags

We've covered some of the basic components of META tags, and then we'll look at the common features of META tags:

1, Help homepage by the major search engine login

One of the most important features of META tags is to set up keywords to help your homepage be logged in by major search engines, increasing the amount of site visits. In this function, the most important thing is to set the keywords and description. Because according to the search engine work principle, the search engine first sends out the robot automatically retrieves the keywords and the decription in the page, and joins it to own database, then sorts the website according to the keyword density. Therefore, we must set up keywords to improve the search clickthrough rate of the page. Let us give you an example for your reference:

<meta name= "keywords" content= "Web page, Web authoring, Web effects, site guide, tutorials download, animation production, Web teaching, web materials, video tutorials, technology forum, free space, free domain" >
<meta name= "description" content= "Web teaching Network Professional web teaching website" >

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

2, define the use of the page language

This is the most common function of meta tags, we will see it in pure HTML code when making a Web page, it is to define the language of your Web page, when visitors visit your Web page, the browser will automatically recognize and set the language in the page, if your page is set to GB code, and the viewer does not install GB code, The Web page will only render the browser's default language as set by the viewer. Similarly, if the webpage is English, then charset=en. Here is a representative example:

<meta http-equiv=″content-type″content=″text/html; charset=gb2312″〉

This code means that the language of the Web page is set to the GB code.

3, automatically refresh and point to the new page

If you want to make your Web page unattended, you can automatically refresh the Web page by using the META tag to access the specified page within the specified time. Let's take a look at some code:

〈meta http-equiv=″refresh″content=″2; url=http://www.webjx.com″〉

This code allows the current page to automatically go to the http://www.webjx.com page after 2 seconds, which is the role of Meta Refresh, in content, 2 represents the set time (in seconds), and the URL is automatically connected after a specified time page address.

4, the Realization of Web page conversion animation effect

Using meta tags, we can also animate the moment we enter the page or leave the page, just 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 we go into and out of the page, this function is actually the same as the format/page transition in FrontPage2000, but we should note that the added page cannot be a frame page;

5. Website Grading evaluation

IE4.0 or later versions of the browser can prevent browsing some restricted sites, and the browser will automatically identify some sites are restricted, because the site META tag has been set up the level of the site, and that level of assessment is the United States Rsac, that is, the Entertainment Commission rating agencies, If you need to evaluate your site, you can connect to the site http://www.rsac.org/, submit the form as required, then RSAC will provide a meta code for you, copy it to your own web page. Here is a sample code:

〈meta Http-equiv=″pics-label″
content=′ (Pics-1.1″http://www.rsac.org/ratingsv01.html″
L Gen True Comment″rsaci North America Server″
For″http://www.rsac.org″
On″2001.08.16t08:15-0500″
R (N 0 s 0 v 0 L 0)) ′〉

6. Control page Buffering

Meta tags can set the time the page expires, that is, when you set the browser in Internet Explorer to view the page in the local buffer first, then when browsing a page, and local buffering and sometimes, then the browser will automatically browse the buffer in the page, The browser will not get a new page until the time set in the meta expires. For example, the following code indicates that the expiry time of the Web page is January 12, 2001 18:18 18 seconds.

〈meta Http-equiv=″expires″content=″friday, 12-jan-2001 18:18:18 gmt″〉

7. Control the window displayed on the page

We can also use META tags to control the window displayed on the page, as long as the page to add the following code: <metahttp-equiv= "Window-target" content= "_top" >, This code prevents the page from being called by someone else 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: 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.