Detailed explanation of meta tags

1. Basic introduction to meta

       The <meta> tag is an important tag in the source code of HTML pages. meta is used to describe the attributes of an html web document, such as author, date and time, keywords, page refresh. In addition, meta-information about the page can be provided, such as description and keywords for search engines and update frequency. It is inside the <head> element and contains no content.

Second, the attributes of meta

 ① Required attributes

       content property. This attribute is to define meta-information related to http-equiv or name attribute, the content of which is used to facilitate search robots to find information and classify.

  ② Optional attributes

       name attribute. This attribute is mainly used to describe web pages. The value of the name attribute can be: author, description, keywords, generator, etc.

      http-equiv attribute. This attribute is equivalent to the function of the http header file, which can return some useful information to the browser to help display the content correctly and accurately. The value of the http-equiv attribute can have content-type, expires, refresh, etc.

3. The name attribute

       The value of the name attribute: author, description, keywords, generator, revised, others.

       The two attribute values ​​of description and keywords are put together because their functions are very similar. Because setting these two values ​​can help your homepage be landed by major search engines and increase the traffic of your website. Therefore, the setting of these two attribute values ​​is particularly important. Because according to the working principle of search engines, search engines will first exclude keywords and descriptions in the pages that are automatically retrieved by robots, add them to their own database, and then sort websites according to the density of keywords. E.g:

<meta name="keywords" content="About meta tags">
<meta name="description" content="How to use the <meta> tag correctly in HTML">
Note:  The content of keywords should be limited to 36 characters.
      The content of description should be limited to 76 characters.

      It is worth noting that name must be used in conjunction with the content attribute.

4. http-equiv attribute

  •       Attribute values ​​of http-equiv: content-type, expires, refresh, set-cookie.
          ① content-type (document content type: used to set the type and character set of the document)
      This is the most common setting in meta notes. When making a web page, we can see in the pure HTML code that it defines you The language of the web page, when the browser accesses your web page, the browser will identify and set accordingly, otherwise, the browser will use the default setting method.
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
  •       ②  expires (period: can be used to set the expiration period of the webpage)
      Once the webpage expires, it must be refreshed on the server and the webpage cannot be obtained through the cache. It is worth noting that the time set in it must be in GMT format.
  • <meta http-equiv="expires" content="Fri,12 Jan 2001 15:15:15 GMT">
      If you set the browser page to be fetched from the page in the local cache first, then when browsing, it will only be fetched from the local cache, and the browser will not fetch the new page until the time set in the meta expires.
            ③ pragma (cash mode: whether to access web content from the cache)
  • <meta http-equiv="pragma" content="no-cache">
             This line of code means that the page is not fetched from the cache, so the visitor will not be able to work offline. ④ refresh (refresh: wait for a certain time to automatically refresh or jump to other urls)
             
  • <meta http-equiv="refresh" content="1; url=https://www.baidu.com"/>

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324851747&siteId=291194637