A collection of common uses of HTML meta tags

A collection of common uses of HTML meta tags

What is a mata tag
The <meta> element provides meta-information about the page, such as a description and keywords for search engines and update frequency.
The <meta> tag is placed in the head of the document and contains no content. The attributes of the <meta> tag define name/value pairs associated with the document.
meta is an auxiliary tag in the head area of ​​html language. We can see meta tags in almost all web pages, but they are not visible in the browser display page. Maybe you think these codes are dispensable. In fact, meta tags are very important and will bring practical effects to your website. For example, the website description () will be reflected in the search engine index. For example, use meta tags to set the website encoding to gbk2312 or utf-8. Meta tags set keywords

Basic syntax

XML/HTML CodeCopy content to clipboard
  1. < meta    name = "keywords"     content = "Keyword 1, Keyword 2, Keyword 3..." >   

The function of keyword tag is to tell search engines what the content of the website is about, so as to facilitate search engines to define and index the website. Keywords are separated by commas in English input method, and the length of keywords is generally not more than 100 characters.
For example, if our website is about learning Web development technology, the keyword description can be written like this:

XML/HTML CodeCopy content to clipboard
  1. < meta    name = "keywords"     content = "html tutorial,css tutorial,javascript tutorial" >   

When users search for these keywords on search engines, your website will appear in the results. However, since many cheaters (black hat SEO) used keyword stacking in the early days, search engines (Baidu) are no longer so sensitive to keywords.

meta tag setting description
Syntax:

XML/HTML CodeCopy content to clipboard
  1. < meta    name = "discription" content = "description content" >   

The description of the web page is very important and can be directly reflected in the search engine. For example, when you open the Baidu website and search for "Sina", you will see the following page:

Meta tag to set character set
Syntax:

XML/HTML CodeCopy content to clipboard
  1. < meta   http-equiv ="content-type" content ="text/html; charset ="encoding" >   

Common encoding formats include Chinese encoding (gbk2312) and international encoding (UTF-8). gbk2312 is Chinese encoding. If your website content is all in Chinese, use gbk2312. UTF-8 is universal for text around the international encoding (including Chinese and English). The main difference between them is that gbk2312 is specially designed for Chinese, and one Chinese character occupies 2 characters. UTF-8 is universal, and one Chinese character occupies 3 bytes. In the early days, network bandwidth resources were scarce, so using gbk2312 encoding could save bandwidth and increase the speed of opening web pages, but now our home bandwidth is 4M and above, and we completely ignore the saved bytes.
Example:

XML/HTML CodeCopy content to clipboard
  1. < meta   http-equiv = "Content-Type"   content = "text/html; charset=utf-8"   >   

When we browse the web, most people have encountered garbled pages. The encoding format allows the browser to parse in a set editing format. If the encoding format is incorrect, garbled characters will appear. So I suggest using the universal UTF-8 encoding, so that all browsers around the world can display our web pages normally.

Meta tag to set automatic refresh time
Syntax

XML/HTML CodeCopy content to clipboard
  1. < meta   http-equiv ="refresh" content ="refresh interval time" >   

The refresh time is in seconds. For example, the forum page can only see new posts after refreshing. For pages that update quickly like this, you can add automatic refresh code to ensure that you can see the latest page.
Example:

XML/HTML CodeCopy content to clipboard
  1. < meta   http-equiv ="refresh" content ="3" >   

Here we set the time to 3 seconds, please test it yourself.

Meta tag setting automatically jumps to a new page
Syntax

XML/HTML CodeCopy content to clipboard
  1. < meta   http-equiv ="refresh" content ="Number of seconds between jumps; Url ="new web page address" >   

Example:

XML/HTML CodeCopy content to clipboard
  1. < meta   http-equiv ="refresh" content ="3; Url ="http://www.adminwang.com" >   

When the browser opens this page, it will automatically jump to the homepage of our website after 3 seconds.

Meta tag setting to disable cache
Syntax

XML/HTML CodeCopy content to clipboard
  1. < meta   http-equiv = "cache-control"    content = "no-cache"   />   

We know that browsers have a cache mechanism, which means that when you open a web page, it will be automatically saved locally. The purpose of this is to directly call the cached files when you visit it again within a certain period of time to improve the access speed. However, for pages like forums that change from time to time, we don't want the browser to save cache files, so we can add this code. There is another use in program development. If you want to check the effect of code modifications from time to time during program debugging, you can use this code to disable browser cache.
Another way to write it:

XML/HTML CodeCopy content to clipboard
  1. < meta   http-equiv = "pragma"   content = "no-cache"   >   

<<:  Detailed steps for deploying Microsoft Sql Server with Docker

>>:  Solution to "Specialized key was too long" in MySQL

Recommend

Faint: "Use web2.0 to create standard-compliant pages"

Today someone talked to me about a website develo...

JavaScript explains the encapsulation and use of slow-motion animation

Implementing process analysis (1) How to call rep...

10 Popular Windows Apps That Are Also Available on Linux

According to data analysis company Net Market Sha...

js canvas realizes slider verification

This article example shares the specific code of ...

Detailed explanation of how to cleanly uninstall Docker

First, the server environment information: Reason...

MySQL restores data through binlog

Table of contents mysql log files binlog Binlog l...

Docker port mapping and external inaccessibility issues

The Docker container provides services and listen...

MySQL group query optimization method

MySQL handles GROUP BY and DISTINCT queries simil...

How to write the parent and child directories of HTML relative paths

How to indicate the parent directory ../ represent...

Common browser compatibility issues (summary)

Browser compatibility is nothing more than style ...

Vue implements start time and end time range query

This article shares with you how to query the sta...

jQuery implements time selector

This article example shares the specific code of ...