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

TypeScript uses vscode to monitor the code compilation process

Install Install ts command globally npm install -...

Detailed explanation of three relationship examples of MySQL foreign keys

This article uses examples to describe the three ...

Implementation of multi-port mapping of nginx reverse proxy

Code Explanation 1.1 http:www.baidu.test.com defa...

How to process blob data in MySQL

The specific code is as follows: package epoint.m...

...

Detailed explanation of js closure and garbage collection mechanism examples

Table of contents Preface text 1. Closure 1.1 Wha...

Use CSS to easily implement some frequently appearing weird buttons

background In the group, some students will ask r...

Detailed explanation of the use of default in MySQL

NULL and NOT NULL modifiers, DEFAULT modifier, AU...

The best solution for resetting the root password of MySQL 8.0.23

This method was edited on February 7, 2021. The v...

How to make React components full screen

introduce This article is based on React + antd t...

Remote development with VSCode and SSH

0. Why do we need remote development? When develo...

How to modify the forgotten password when installing MySQL on Mac

1. Install MySQL database on mac 1. Download MySQ...