Mobile terminal work has increasingly become an important part of front-end work. In addition to ordinary project development, the HTML header tag function, especially the meta tag, is very important.
The head section of the HTML document usually includes specifying the page title, providing search engines with information about the page itself, loading the style sheet, and loading the JavaScript file (out For performance reasons, most of the time JavaScript is loaded before the end of the
tag at the bottom of the page). Except for the title, the content in the head is invisible to page visitors.
The following is an example of the head part of an HTML document:
DOCTYPE (Document Type) , this declaration is located at the very beginning of the document, before the html tag. This tag tells the browser which HTML or XHTML specification the document uses.
Use HTML5 doctype, case-insensitive.
title element
The head element must contain a title element. The content of this element will appear in the browser's tab page or in The top of the browser window, used as the page title, is related to the browser.
base element
The base element is used to set a base URL on which relative links in HTML documents are parsed. If not specified, the URL of the currently loaded document is used. The base element can also set how the link opens when the user clicks it, and how the browser reacts when the form is submitted.
2) The target attribute specifies where to open all links on the page, including the value:
1) _blank: Open the connected document in a new window; 2) _self: By default, the linked document is opened in the same frame; 3) _parent: Open the linked document in the parent frame; 4) _top: Open the linked document in the entire window; 5) framename: Opens the linked document in the specified frame.
meta element
The meta element is used to define various metadata of the document. The meta element can be used for multiple purposes, but each meta element can only be used for one If you need to use more than one, you need to add multiple meta elements to the head element.
Specify name/value metadata pair
<meta name="author" content="Adam Freeman"/>
Copy after login
The name attribute is used to indicate the type of metadata, and the content attribute provides the value. The name attribute contains the following values:
1) application name: the name of the Web application system to which the current page belongs; 2) author: the name of the author of the current page; 3) description: description of the current page ; 4) generator: the name of the software used to generate HTML; 5) keywords: describes the content of the page.
In addition to the above 5 predefined metadata names, you can also use metadata extensions. Here (http://wiki.whatwg.org/wiki/MetaExtensions) there is a frequently updated list of these extensions . Some extensions are used more often, such as robots metadata, which the author of an HTML document can use to tell search engines how to treat the document:
<meta name="robots" content="noindex"/>
Copy after login
This attribute has three majorities Values recognized by search engines:
1) noindex: Do not index this page; 2) noarchive: Do not archive or cache this page; 3) nofollow: Do not follow the content of this page Link to continue searching.
Most search engines provide guides for optimizing web pages or entire websites. You can view the web page or website optimization guides provided by the corresponding search engines.
Declare character encoding
<meta charset="utf-8" />
Copy after login
The meta element in the head element declares that the character encoding of the document is UTF-8 (default).
Simulate HTTP header fields
Themeta element can be used to simulate or replace the values of three HTTP header fields.
<meta http-equiv="refresh" content="5"/>
Copy after login
The purpose of the http-equiv attribute is to specify the name of the header field to be simulated, and the field value is specified in the content attribute. The optional values of the http-equiv attribute are as follows:
1) refresh: Specify a time interval in seconds, after which the current page will be reloaded from the server. You can also specify a URL for the browser to load, such as:
2) default-style: Specify the style sheet to be used first on the page. The value of the content attribute must be The title attribute value of a style element or link element in the same document;
3) content-type: Another way to declare the character encoding used in the HTML page, such as:
A new style is designed for the a element above. The style element can appear in various parts of the HTML document. A document can contain multiple style elements. This element can be used to supplement the style defined by the template (link element import).
可以为style元素指定样式适用的媒体:
<style media="screen AND (min-width:500px)" type="text/css">
......
</style>
The above is the detailed content of Detailed explanation of the head of html5. For more information, please follow other related articles on the PHP Chinese website!
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