Home > Web Front-end > H5 Tutorial > body text

Detailed analysis of html meta tag usage and attributes

不言
Release: 2019-04-15 13:12:58
forward
3496 people have browsed it

This article brings you a detailed analysis of the use and attributes of html meta tags. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you. .

Since I started self-studying the front-end, I didn’t have much contact with meta tags. I mainly focused on tags that can be displayed, such as span, button, h1, etc. Sometimes I check the source code of some well-known websites and find a lot of meta in the head tag.

Today let’s learn the use of meta and see what attributes it has.

1. Definition and function

meta, that is, metadata (Metadata) is the data information of data.

This tag provides metadata for the HTML document. The metadata will not be displayed on the client, but will be parsed by the browser.

is usually used to specify the description, keywords, last modification time of the file, author and other metadata of the web page.

Metadata can be called using browsers (how content is displayed or pages are reloaded), search engines (keywords), or other web services.

2. Attributes

charset(new in htm5) Definition document The character encoding
#content  defines meta-information related to the http-equiv or name attribute.
http-equiv http response header
name     Attribute name
scheme (htm5 obsolete) Scheme for translating the value of the content attribute

1 , charset

HTML5 new attribute, defines the character encoding of the current page

New writing method:

<meta charset="UTF-8">
Copy after login

Old writing method:

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
Copy after login

HTML5 The new writing method is preferred

2. Name attribute

a. Keywords, keywords of the current web page, to facilitate search engine identification and improve search accuracy

<meta name="keywords" content="cdn,网络加速,运营商">
Copy after login

b, description, a brief description of the current web page. If you search with Baidu, the description content will be displayed under each title of the search results to facilitate users to quickly locate

<meta name="description" content="本公司专注提供CDN网络加速,同时也提供云计算服务">
Copy after login

c, viewport, this Meta is a bit complicated. It is mainly used in mobile web pages and requires a separate article. I will temporarily skip

<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />
Copy after login

d and robots. The indexing method of search engine crawlers

<meta name="robots" content="none">
Copy after login

content value There are all, none, index, noindex, follow, and nofollow. The default is all. The specific instructions are as shown in the table:

allDocuments can be Index, the links in the document can be queried
noneThe document cannot be indexed, and the links in the document cannot be queried
indexThe document can be indexed
noindexThe document cannot be indexed, but the links in the document can be queried
followThe links in the document can be queried
nofollowThe document can be indexed, but the The link cannot be queried

e, author, the author of the document

<meta name="author" content="liuhw,liuhuansir@126.com">
Copy after login

f, copyright, the copyright statement of the document

<meta name="copyright" content="liuhw">
Copy after login

g, revisit-after, the time interval for search engine crawlers to revisit. If your website is not updated frequently, you can set this time to be slightly longer, which can slightly reduce the pressure on the server and save bandwidth resources

<meta name="revisit-after" content="5 days" >
Copy after login

h. renderer, the rendering method of dual-core browsers, specifies which browser core is used for rendering by default, for example, 360 browser:

<meta name="renderer" content="webkit"> //默认webkit内核
<meta name="renderer" content="ie-comp"> //默认IE兼容模式
<meta name="renderer" content="ie-stand"> //默认IE标准模式
Copy after login

3, http-equiv

Simulate the header in http and send some information back to the server

a, expires, the expiration time of the web page, after expiration, you need to revisit the server

<meta http-equiv="expires" content="Sunday 26 October 2018 01:00 GMT" />
Copy after login

b, pragma (compatible with http1.0 , 1.1), cache-control (new in http1.1), set the cache method, it is recommended to use cache-control, the content of this attribute refers to cache-control

<meta http-equiv="cache-control" content="no-cache">
Copy after login

c, refresh in http, automatic refresh And jump to the url

<meta http-equiv="refresh" content="5;URL=http://www.liuhw.club/"> //5秒后跳转向我自己的域名
Copy after login

d and set-cookie declared in content, add cookie

<meta http-equiv="set-cookie" content="TOKEN_KEY=81BBF72619795017B6AC214AE705F1F8; Domain=10.1.100.111; Path=/">
Copy after login

e, content-Type, the character encoding of the document, the same as charset, it is recommended to use charset

<meta http-equiv="content-type" content="text/html;charset=gb2312">
Copy after login

f, x-ua-compatible, tell the browser which version to use to render the document

<meta http-equiv="x-ua-compatible" content="IE=edge,chrome=1"/> //指定IE和Chrome使用最新版本渲染当前页面
Copy after login

To summarize, the above only lists some commonly used attributes, and those that are not listed are needed. Check the documentation later

[Related recommendations: HTML5 video tutorial]

The above is the detailed content of Detailed analysis of html meta tag usage and attributes. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:cnblogs.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!