Home > Article > Web Front-end > What is the meta tag in html? Introduction to attributes of meta tag
This chapter will introduce to you what is the meta tag in html? Introduction to the attributes of meta tags. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.
What is a meta tag?
## The meta tag is a key tag in the head area of the HTML tag. It is located between the andWhat are the attributes of the meta tag?
Detailed explanation of attributes:
1.http-equiv is equivalent to http The function of the file header is that it can return some useful information to the browser to help the browser correctly display the content of the web page. Syntax: Parameters: 1) content-Type (set page usage Character set)<metahttp-equiv="content-Type" content="text/html;charset=gb2312">http-equiv=Content-Type represents the HTTP header protocol, prompting the browser for web page information. The information parameter of the charset of the meta tag is such as GB2312. , which means that the encoding used by the website is Simplified Chinese; when the information parameter of the charset of the meta tag is such as BIG5, it means that the encoding used by the website is Traditional Chinese; the charset of the meta tag When the information parameter is such as iso-2022-jp, it means that the encoding used by the website is Japanese; when the information parameter of the charset 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 charset information parameter of the
meta tag is such as UTF-8, it means the world Universal language encoding;
2) content-Language (display language setting)
<meta http-equiv="Content-Language" content="zh-cn"/>
3) Expires (period, which can be used to set the expiration time of the web page. Once the web page expires , must be retransmitted to the server)
<meta http-equiv="expires" content="Fri,12Jan200118:18:18GMT">
Note: The GMT time format must be used.
4) Pragma (cache mode, prohibits the browser from accessing page content from the cache of the local computer)
<meta http-equiv="Pragma" content="no-cache">
Note: With this setting, visitors will not be able to browse offline.
5) cache-control (cache settings)
<meta http-equiv="cache-control" content="no-cache">
The cache instructions when requesting include no-cache, no-store, max-age, max-stale, min-fresh, only- if-cached, the instructions in the response message include public, private, no-cache, no-store, no-transform, must-revalidate, proxy-revalidate, and max-age. The meaning of the instructions in each message is as follows:
Public indicates that the response can be cached by any cache area
Private indicates that the entire or partial response message for a single user cannot be processed by the shared cache. This allows the server to only describe when a user's partial response message is invalid for other users' requests
no-cache indicates that the request or response message cannot be cached
no-store is used to prevent important information was released unintentionally. Sending it in the request message will cause both the request and response messages to use caching.
max-age indicates that the client can receive responses with a lifetime no greater than the specified time in seconds
min-fresh indicates that the client can receive responses with a lifetime less than the current time plus the specified Time-of-response
max-stale indicates that the client can receive response messages beyond the timeout period. If you specify a value for max-stale messages, the client can receive response messages that exceed the specified value of the timeout period.
6) Refresh (automatically refresh and point to the new page)
<meta http-equiv="Refresh" content="2; URL=http://www.baidu.com"> //(注意后面的引号,分别在秒数的前面和网址的后面)
Note: The 2 refers to automatically refreshing to the URL after staying for 2 seconds.
7) Window-target (force the page to be displayed as an independent page in the current window)
<meta http-equiv="Window-target" content="_top">
8) set-cookie (cookie setting, if the web page expires, the saved cookie will be deleted)
<meta http-equiv="Set-Cookie" content="cookie value=xxx; expires=Friday,12-Jan-200118:18:18GMT;path=/">
It is usually used to force the browser not to set a cache and re-obtain the page from the server. The following method:
<meta http-equiv=”pragma” content=”no-cache”> <meta http-equiv=”cache-control” content=”no-cache”> <meta http-equiv=”expires” content=”0″>2.name attribute
The name attribute is mainly used to describe the web page. The corresponding attribute value is content. The content in content is mainly It is convenient for search engine robots to find and classify information.
Syntax:
<meta name="参数" content="具体的参数值">
Keywords(keywords)
Description: keywords are used to tell search engines what the keywords of your web page are.
<meta name="keywords" content="">
description(网站内容描述)
说明:description用来告诉搜索引擎你的网站主要内容。
<metaname="description" content="">
robots(机器人向导)
说明:Meta robots标签管理着搜索引擎是否可以进入网页,你可以用它来允许或不允许搜索引擎来获取你的网页、进入你网页中的子链接或对你的网页存档。content的参数有all,none,index,noindex,follow,nofollow。默认是all。
<metaname="robots" content="none">
具体参数如下:
信息参数为all:文件将被检索,且页面上的链接可以被查询;
信息参数为none:文件将不被检索,且页面上的链接不可以被查询;
信息参数为index:文件将被检索;
信息参数为follow:页面上的链接可以被查询;
信息参数为noindex:文件将不被检索,但页面上的链接可以被查询;
信息参数为nofollow:文件将被检索,但页面上的链接不可以被查询;
author(作者)
说明:标注网页的作者
<metaname="author" content="jesse131work@163.com">
generator
说明:meta标签的generator的信息参数,代表说明网站的采用的什么软件制作。
<metaname="generator" content="信息参数"/>
copyright
说明:meta标签的copyright的信息参数,代表说明网站版权信息。
<metaname="copyright" content="信息参数">
revisit-after
说明:revisit-after代表网站重访,7days代表7天,依此类推,假如我设置,那这样搜索引擎就是7天来一次。使用这个标签的网站,通常是因为网站数据量非常大,被搜索引擎过 于频繁的抓取,会占用过大的资源,影响网站的访问。所以,希望搜索引擎不要天天过来,抓取过一次了,那么等7天后再来。一般的网站是不需要这个标签的。
view-point
说明:主要影响移动页面布局
<meta name="viewport" content="width=device-width, initial-scale=1.0">
content 参数:
width viewport 宽度(数值/device-width)
height viewport 高度(数值/device-height)
initial-scale 初始缩放比例
maximum-scale 最大缩放比例
minimum-scale 最小缩放比例
user-scalable 是否允许用户缩放(yes/no)
3.content属性
content属性一般与name和http-equiv属性一起用,视它们的值而定。
4.charset属性
charset属性,是html5的属性,可替换
设置meta属性的作用是什么?
meta标签提供关于HTML文档的元数据。元数据不会显示在页面上,但是对于机器是可读的。它可用于浏览器(如何显示内容或重新加载页面),搜索引擎(关键词),或其他 web 服务。meta标签可用于缓存设置,还与SEO优化相关。SEO是指通过采用易于搜索引擎索引的合理手段,使网站各项基本要素适合搜索引擎检索原则并且对用户更友好(Search Engine Friendly),从而更容易被搜索引擎收录及优先排序从属于SEM(搜索引擎营销)。通俗理解是:通过总结搜索引擎的排名规律,对网站进行合理优化,使你的网站在百度和goog的排名提高,让搜索引擎给你带来客户。
seo优化常用语句如下
<!-- 页面标题<title>标签(head 头部必须) --> <title>your title</title> <!-- 页面关键词 keywords --> <meta name="keywords" content="your keywords"> <!-- 页面描述内容 description --> <meta name="description" content="your description"> <!-- 定义网页作者 author --> <meta name="author" content="author,email address"> <!-- 定义网页搜索引擎索引方式,robotterms 是一组使用英文逗号「,」分割的值,通常有如下几种取值:none,noindex,nofollow,all,index和follow。 --> <meta name="robots" content="index,follow">
The above is the detailed content of What is the meta tag in html? Introduction to attributes of meta tag. For more information, please follow other related articles on the PHP Chinese website!