Home > Article > Web Front-end > How to use meta tags? How to use meta tags
What this article brings to you is how to use meta tags? The method of using meta tags has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.
Composition of meta tag: meta tag has two attributes, they are http-equiv attribute and name attribute. Different attributes have different parameter values. These different parameter values are implemented Different web page features.
1. name attribute
The name attribute is mainly used to describe web pages, and the corresponding attribute value is content. The content in content is mainly used by search engine robots to find information and classify information. .
The syntax format of the name attribute of the meta tag is:
<meta name="参数" content="具体的参数值">
The name attribute mainly has the following parameters:
①Keywords(Keywords)
Description: keywords are used to tell search engines what the keywords of your web page are.
Example:
<meta name="keywords" content="meta总结,html meta,meta属性,meta跳转">
②description (website content description)
Description: description is used to tell search engines the main content of your website.
Example:
<meta name="description" content="haorooms博客,html的meta总结,meta是html语言head区的一个辅助性标签。">
③robots (robot guide)
Description: robots are used to tell the search robot which pages need to be indexed and which pages do not need to be indexed . The parameters of
content include all, none, index, noindex, follow, and nofollow. The default is all.
Example:
<meta name="robots" content="none">
The specific parameters are as follows:
The information parameter is all: the file will be retrieved, and the links on the page can be queried;
The information parameter is none: The file will not be retrieved, and the links on the page cannot be queried;
The information parameter is index: the file will be retrieved;
The information parameter is follow: The links on the page can be Be queried;
The information parameter is noindex: the file will not be retrieved, but the links on the page can be queried;
The information parameter is nofollow: the file will be retrieved, but the links on the page Cannot be queried;
④author(author)
Description: Mark the author of the web page
Example:
<meta name="author" content="root,root@xxxx.com">
⑤generator
<meta name="generator" content="信息参数"/>
The information parameters of the generator in the meta tag represent the software used to create the website.
⑥copyright
<meta name="copyright" content="信息参数">
The COPYRIGHT information parameter of the meta tag represents the copyright information of the website.
⑦revisit-after
<meta name="revisit-after" content="7days">
revisit-after represents website revisit, 7days represents 7 days, and so on.
http-equiv, as the name suggests, is equivalent to the file header function of http. It can return some useful information to the browser to help display it correctly and accurately. Web page content, the corresponding attribute value is content, and the content in content is actually the variable value of each parameter.
The http-equiv attribute syntax format of the meta tag is:
<meta http-equiv="参数"content="参数变量值">;
The http-equiv attribute mainly has the following parameters:
①Expires(period)
Description: Can be used to set the expiration time of the web page. Once a web page expires, it must be retransmitted to the server.
Usage:
<meta http-equiv="expires" content="Fri,12Jan200118:18:18GMT">
Note: GMT time format must be used.
②Pragma (cache mode)
Description: Prohibit the browser from accessing page content from the cache of the local computer.
Usage:
<meta http-equiv="Pragma"content="no-cache">
Note: With this setting, visitors will not be able to browse offline.
③Refresh(refresh)
Description: Automatically refresh and point to the new page.
Usage:
<meta http-equiv="Refresh" content="2;URL=http://www.haorooms.com">// (注意后面的引号,分别在秒数的前面和网址的后面)
Note: The 2 refers to automatically refreshing to the URL after staying for 2 seconds.
④Set-Cookie (cookie setting)
Note: If the web page expires, the saved cookies will be deleted.
Usage:
<meta http-equiv="Set-Cookie"content="cookie value=xxx;expires=Friday,12-Jan-200118:18:18GMT;path=/">
Note: GMT time format must be used.
⑤Window-target (display window setting)
Description: Force the page to be displayed as an independent page in the current window.
Usage:
<meta http-equiv="Window-target"content="_top">
Note: Used to prevent others from calling your own page in the frame.
⑥content-Type (display character set setting)
Description: Set the character set used by the page.
Usage:
<meta http-equiv="content-Type"content="text/html;charset=gb2312">
The details are as follows:
When the charset information parameter of the meta tag is such as GB2312, it means that the encoding used by the website is Simplified Chinese;
meta When the charset information parameter of the tag is such as BIG5, it means that the encoding used by the website is Traditional Chinese; when the charset information parameter of the
meta tag is such as iso-2022-jp, it means that the encoding used by the website is Traditional Chinese Japanese; when the charset information parameter of the
meta tag is such as ks_c_5601, it means that the encoding used by the website is Korean; when the charset information parameter of the
meta tag is such as ISO-8859-1, It means that the encoding used by the website is English; when the information parameter of the charset of the
meta tag is such as UTF-8, it represents the world's universal language encoding;
⑦content-Language (display Language settings)
Usage:
<meta http-equiv="Content-Language"content="zh-cn"/>
⑧Cache-Control specifies the caching mechanism followed by requests and responses.
Cache-Control指定请求和响应遵循的缓存机制。在请求消息或响应消息中设置Cache-Control并不会修改另一个消息处理过程中的缓存处理过程。请求时的缓存指令包括no-cache、no-store、max-age、max-stale、min-fresh、only-if-cached,响应消息中的指令包括public、private、no-cache、no-store、no-transform、must-revalidate、proxy-revalidate、max-age。各个消息中的指令含义如下:
Public指示响应可被任何缓存区缓存;
Private指示对于单个用户的整个或部分响应消息,不能被共享缓存处理。这允许服务器仅仅描述当用户的部分响应消息,此响应消息对于其他用户的请求无效;
no-cache指示请求或响应消息不能缓存;
no-store用于防止重要的信息被无意的发布。在请求消息中发送将使得请求和响应消息都不使用缓存;
max-age指示客户机可以接收生存期不大于指定时间(以秒为单位)的响应;
min-fresh指示客户机可以接收响应时间小于当前时间加上指定时间的响应;
max-stale指示客户机可以接收超出超时期间的响应消息。如果指定max-stale消息的值,那么客户机可以接收超出超时期指定值之内的响应消息。
⑨http-equiv=”imagetoolbar”
<meta http-equiv="imagetoolbar"content="false"/>
指定是否显示图片工具栏,当为false代表不显示,当为true代表显示。
⑩Content-Script-Type
<meta http-equiv="Content-Script-Type" Content="text/javascript">
以上就是对meta标签如何使用?meta标签使用方法的全部介绍,如果您想了解更多有关HTML视频教程,请关注PHP中文网
The above is the detailed content of How to use meta tags? How to use meta tags. For more information, please follow other related articles on the PHP Chinese website!