There are many tags and elements in the HTML head part, which are related to the browser's rendering of web pages, SEO, etc., and each browser kernel and each domestic browser manufacturer has some of their own tag elements, which causes a lot of differences. In the era of mobile Internet, the head structure and meta elements of the mobile terminal become more important. The purpose of this article is to understand the meaning of each tag and write a head tag that meets your needs. This article is based on Yisi's article and expands on the summary to introduce the meaning and usage scenarios of various tags and elements in the commonly used head. DOCTYPE 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. The DTD (Document Type Definition) declaration starts with <!DOCTYPE>, which is case-insensitive. There is nothing in front of it. If there is other content (except spaces), the browser will render the web page in quirks mode under IE. Public DTD, the name format is registration//organization//type tag//language, registration refers to whether the organization is registered by the International Organization for Standardization (ISO), + means yes, - means no. Organization is the name of the organization, such as W3C. The type is generally DTD. A tag specifies a public text description, which is a unique descriptive name for the referenced public text, optionally followed by a version number. The last language is the ISO 639 language identifier of the DTD language, such as EN for English and ZH for Chinese. XHTML 1.0 can declare three DTD types. Respectively represent strict version, transitional version, and frame-based HTML documents. ●HTML 4.01 strict XML/HTML CodeCopy content to clipboard
XML/HTML CodeCopy content to clipboard
XML/HTML CodeCopy content to clipboard
XML/HTML CodeCopy content to clipboard
The doctype has two main purposes in HTML. ●Verify the validity of documents. It tells user agents and validators what DTD the document was written in. This action is passive. The browser does not download the DTD and check the validity every time the page is loaded. It is only enabled when the page is manually verified. ●Determine the browser's rendering mode For actual operation, tell the browser which parsing algorithm to use when reading the document. If it is not written, the browser will parse the code according to its own rules, which may seriously affect the HTML layout. There are three ways for browsers to parse HTML documents. ●Non-weird (standard) mode●Weird mode●Partially weird (near-standard) mode Regarding IE's document mode, browser mode, strict mode, quirks mode, and DOCTYPE tag, you can read Mode in detail? standard! content. charset Declare the character encoding used by the document, XML/HTML CodeCopy content to clipboard
Before HTML5, web pages would be written like this: XML/HTML CodeCopy content to clipboard
These two are equivalent, as described in <meta charset='utf-8'> vs <meta http-equiv='Content-Type'>, so it is recommended to use the shorter one that is easier to remember. XML/HTML CodeCopy content to clipboard
Traditional Chinese XML/HTML CodeCopy content to clipboard
Why is it lang="zh-cmn-Hans" instead of the usual lang="zh-CN"? Please read: Should the declaration in the page header use lang="zh" or lang="zh-cn"? XML/HTML CodeCopy content to clipboard
360 Using Google Chrome Frame XML/HTML CodeCopy content to clipboard
After reading this tag, the 360 browser will immediately switch to the corresponding high-speed core. In addition, for the sake of insurance, add XML/HTML CodeCopy content to clipboard
The effect achieved by writing this way is that if Google Chrome Frame is installed, GCF is used to render the page. If GCF is not installed, the highest version of IE kernel is used for rendering. Related links: Browser kernel control Meta tag description document XML/HTML CodeCopy content to clipboard
Related link: SiteApp Transcoding Statement XML/HTML CodeCopy content to clipboard
Page keywords XML/HTML CodeCopy content to clipboard
XML/HTML CodeCopy content to clipboard
Define the author of the web page XML/HTML CodeCopy content to clipboard
Defines how web search engines index web pages. Robotterms is a set of values separated by commas "," and usually has the following values: none, noindex, nofollow, all, index, and follow.
Related Link: WEB1038 - Tag contains an invalid value The viewport allows the layout to display better on mobile browsers. Usually write XML/HTML CodeCopy content to clipboard
width=device-width will cause black edges to appear when opening the page in WebApp full-screen mode after adding it to the home screen on iPhone 5 (http://bigc.at/ios-webapp-viewport-meta.orz) content parameter: width viewport width (value/device-width) XML/HTML CodeCopy content to clipboard
If your website is not responsive, please do not use initial-scale or disable scaling. XML/HTML CodeCopy content to clipboard
Related link: Non-responsive viewport
Most 4.7~5-inch Android devices have a viewport width of 360px, but on iPhone 6 it is 375px. Most 5.5-inch Android devices (such as Samsung Note) have a viewport width of 400, but on iPhone 6 plus it is 414px. XML/HTML CodeCopy content to clipboard
XML/HTML CodeCopy content to clipboard
Set the background color of the status bar XML/HTML CodeCopy content to clipboard
Only works when "apple-mobile-web-app-capable" content="yes" XML/HTML CodeCopy content to clipboard
iOS Icons rel parameter: apple-touch-icon The image is automatically processed with rounded corners, highlights and other effects. apple-touch-icon-precomposed prohibits the system from automatically adding effects and directly displays the original design. iPhone and iTouch, default 57x57 pixels, must have Copy code The code is as follows:<link rel="apple-touch-icon-precomposed" href="/apple-touch-icon-57x57-precomposed.png" /> <!-- iPhone and iTouch, default 57x57 pixels, required --> iPad, 72x72 pixels, optional but recommended Copy code The code is as follows:<link rel="apple-touch-icon-precomposed" sizes="72x72" href="/apple-touch-icon-72x72-precomposed.png" /> <!-- iPad, 72x72 pixels, optional but recommended --> Retina iPhone and Retina iTouch, 114x114 pixels, optional but recommended Copy code The code is as follows:<link rel="apple-touch-icon-precomposed" sizes="114x114" href="/apple-touch-icon-114x114-precomposed.png" /> <!-- Retina iPhone and Retina iTouch, 114x114 pixels, optional but recommended --> Retina iPad, 144x144 pixels, optional but recommended Copy code The code is as follows:<link rel="apple-touch-icon-precomposed" sizes="144x144" href="/apple-touch-icon-144x144-precomposed.png" /> <!-- Retina iPad, 144x144 pixels, optional but recommended --> The iOS icon size is 180×180 on iPhone 6 plus and 120x120 on iPhone 6. To adapt to iPhone 6 plus, you need to add this paragraph Copy code The code is as follows:<link rel="apple-touch-icon-precomposed" sizes="180x180" href="retinahd_icon.png"> iOS Splash Screen iPad vertical screen 768 x 1004 (standard resolution) Copy code The code is as follows:<link rel="apple-touch-startup-image" sizes="768x1004" href="/splash-screen-768x1004.png" /> <!-- iPad vertical screen 768 x 1004 (standard resolution) --> iPad vertical screen 1536x2008 (Retina) Copy code The code is as follows:<link rel="apple-touch-startup-image" sizes="1536x2008" href="/splash-screen-1536x2008.png" /> <!-- iPad vertical screen 1536x2008 (Retina) --> iPad landscape 1024x748 (standard resolution) Copy code The code is as follows:<link rel="apple-touch-startup-image" sizes="1024x748" href="/Default-Portrait-1024x748.png" /> <!-- iPad landscape 1024x748 (standard resolution) --> iPad landscape 2048x1496 (Retina) Copy code The code is as follows:<link rel="apple-touch-startup-image" sizes="2048x1496" href="/splash-screen-2048x1496.png" /> <!-- iPad landscape 2048x1496 (Retina) --> The startup screen of iPhone and iPod touch includes the status bar area. iPhone/iPod Touch vertical screen 320x480 (standard resolution) Copy code The code is as follows:<link rel="apple-touch-startup-image" href="/splash-screen-320x480.png" /> <!-- iPhone/iPod Touch vertical screen 320x480 (standard resolution) --> iPhone/iPod Touch Portrait 640x960 (Retina) Copy code The code is as follows:<link rel="apple-touch-startup-image" sizes="640x960" href="/splash-screen-640x960.png" /> <!-- iPhone/iPod Touch Portrait 640x960 (Retina) --> iPhone 5/iPod Touch 5 Portrait 640x1136 (Retina) Copy code The code is as follows:<link rel="apple-touch-startup-image" sizes="640x1136" href="/splash-screen-640x1136.png" /> <!-- iPhone 5/iPod Touch 5 Portrait 640x1136 (Retina) --> Add Smart App Banner (iOS 6+ Safari) Copy code The code is as follows:<meta name="apple-itunes-app" content="app-id=myAppStoreID, affiliate-data=myAffiliateData, app-argument=myURL"> <!-- Add Smart App Banner (iOS 6+ Safari) --> The image size for iPhone 6 is 750×1294, and for iPhone 6 Plus it is 1242×2148. Copy code The code is as follows:<link rel="apple-touch-startup-image" href="launch6.png" media="(device-width: 375px)"> <link rel="apple-touch-startup-image" href="launch6plus.png" media="(device-width: 414px)"> Windows 8 Copy code The code is as follows:<meta name="msapplication-TileColor" content="#000"/> <!-- Windows 8 tile color --> Windows 8 Tile Icons Copy code The code is as follows:<meta name="msapplication-TileImage" content="icon.png"/> <!-- Windows 8 tile icon --> RSS Subscription Copy code The code is as follows:<link rel="alternate" type="application/rss+xml" title="RSS" href="/rss.xml" /> <!-- Add RSS subscription --> favicon icon Copy code The code is as follows:<link rel="shortcut icon" type="image/ico" href="/favicon.ico" /> <!-- Add favicon icon --> For a more detailed introduction to favicon, please refer to https://github.com/audreyr/favicon-cheat-sheet
More meta tag references
Reference articles:
|
<<: Implementation of CSS child element selection parent element
>>: Detailed explanation of the process of using GPU in Docker
Classification of color properties Any color can ...
Table of contents Select Structure Loop Structure...
A common development need is that we want to coll...
The width of the parent container is fixed. In or...
Recently, new projects have used springcloud and ...
Refer to the official documentation here for oper...
This work uses the knowledge of front-end develop...
There are various environmental and configuration...
Table of contents Basic Configuration Entry file ...
Table of contents process Demo Mini Program Backe...
Assume there are two Linux servers A and B, and w...
Preface The server system environment is: CentOS ...
<br />Use of line break tag<br>The lin...
When we add an svg image to display, react prompt...
1. Create a user: Order: CREATE USER 'usernam...