There are many tags and elements in the HTML head part, which involve browser rendering of web pages, SEO, etc. Each browser core and each domestic browser manufacturer have their own tag elements, which results in a lot of differences. In the era of mobile Internet, the head structure and meta elements of mobile terminals are even more important. Understanding the meaning of each tag and writing a head tag that meets your own needs is the purpose of this article. This article is based on Yishi's article and provides an expanded summary to introduce the meaning and usage scenarios of each tag and element in commonly used heads.
DOCTYPE
DOCTYPE (Document Type), this declaration is located at the frontmost position in the document, before the html tag. This tag tells the browser what kind of HTML the document uses. Or the XHTML specification.
DTD (Document Type Definition) declaration starts with , is not case-sensitive, and has no content in front. If there is other content (except spaces), the browser will open a weird mode under IE ( quirks mode) renders web pages. 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), indicating yes, - indicating no. Organization is the name of the organization, such as: W3C. The type is usually DTD. A tag specifies a description of the public text, that is, a unique descriptive name for the referenced public text, which can be followed by a version number. The final language is the ISO 639 language identifier of the DTD language, such as: EN for English, ZH for Chinese. XHTML 1.0 can declare three DTD types. Represents strict version, transitional version, and frame-based HTML document respectively.
●HTML 4.01 strict
In HTML doctype has two main purposes.
●Verify the validity of documents.
It tells the user agent and validator what DTD this document is written according to. This action is passive. Every time the page is loaded, the browser does not download the DTD and check the validity. It is only enabled when the page is manually verified.
●Determine the browser’s rendering mode
For actual operations, inform 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. Browsers have three ways to parse HTML documents.
●Non-weird (standard) mode
●Weird mode
●Partially weird (almost standard) mode About IE browser’s document mode, browser mode, strict mode, weird mode, DOCTYPE tag, you can learn more Reading mode? standard! content.
charset
Declare the character encoding used by the document,
Before html5, the web page would read like this:
These two are equivalent, please read the details below: vs , so it is recommended to use shorter ones that are easier to remember.
lang attribute
Simplified Chinese
Traditional Chinese
Why is lang="zh-cmn-Hans" instead of the lang="zh-CN" we usually write? Please read: Should the statement at the head of the page be lang="zh" or lang="zh-cn".
Prioritize using the latest version of IE and Chrome
360 Using Google Chrome Frame
360 browser will immediately switch to the corresponding speed core after reading this tag. Also, just to be on the safe side, join
The effect that can be achieved by writing this way is that if Google Chrome Frame is installed, GCF will be used to render the page. If GCF is not installed, the highest version of the IE kernel will be used for rendering.
Related links: Browser Kernel Control Meta Tag Documentation
Baidu prohibits transcoding
When you open a webpage through Baidu mobile phone, Baidu may modify your webpage Transcode, take off your clothes, and put dog skin plaster ads on your body. For this purpose, you can add
Related links: SiteApp transcoding statement
SEO optimization part
Page title
Page keywords keywords
Page description content description
Define web author author
Define the web search engine indexing method. Robotterms is a set of values separated by English commas ",". It usually has the following values: none, noindex, nofollow, all, index and follow.
XML/HTML CodeCopy content to clipboard
Related links: WEB1038 - Tag contains invalid value
viewport
Viewport can make the layout display better on mobile browsers. Usually write
width=device-width will cause black borders to appear when the iPhone 5 is added to the home screen and opened in WebApp full-screen mode (http://bigc.at/ios-webapp-viewport-meta.orz )
content parameter:
width viewport width (numeric value/device-width)
height viewport height (numeric value/device-height)
initial-scale initial scaling ratio
maximum-scale maximum scaling ratio
minimum-scale Minimum zoom ratio
user-scalable Whether to allow user scaling (yes/no)
minimal-ui A new attribute in iOS 7.1 beta 2 can minimize the upper and lower status bars when the page is loaded. This is a Boolean value and can be written directly like this:
And if your website is not responsive, please do not use initial-scale or disable scaling.
Related links: Viewport with non-responsive design
To adapt to iPhone 6 and iPhone 6plus, you need to write:
XML/HTML CodeCopy content to clipboard
The viewport width of most 4.7~5-inch Android devices is set to 360px, but it is 375px on iPhone 6. The viewport width of most 5.5-inch Android devices (such as Samsung Note) is 400, and it is 414px on iPhone 6 plus. .
ios device
Title added to the home screen (new in iOS 6)
Whether to enable WebApp full screen mode
Set the background color of the status bar
Only takes effect when "apple-mobile-web-app-capable" content="yes"
content parameter:
default default value.
black The background of the status bar is black.
black-translucent The background of the status bar is black and translucent. If set to default or black , web content starts from the bottom of the status bar. If set to black-translucent, the web page content fills the entire screen and the top will be obscured by the status bar.
Disable digit recognition as a phone number
iOS icon
rel parameter: apple-touch-icon The image is automatically processed into rounded corners and highlights. apple-touch-icon-precomposed prohibits the system from automatically adding effects and displays the original design directly. iPhone and iTouch, default 57x57 pixels, required
iPad, 72x72 pixels, optional but recommended
Retina iPhone and Retina iTouch, 114x114 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
iOS splash screen
Official documentation: https://developer.apple.com/library/ios/qa/qa1686/_index.html
Reference article: http://wxd.ctrip.com/blog/2013/09/ios7-hig-24/
The iPad startup screen does not include the status bar area.
iPad portrait screen 768 x 1004 (standard resolution)
iPad portrait 1536x2008 (Retina)
iPad landscape 1024x748 (standard resolution)
iPad landscape 2048x1496 (Retina)
The startup screen of iPhone and iPod touch includes the status bar area.
iPhone/iPod Touch portrait screen 320x480 (standard resolution)
iPhone/iPod Touch portrait screen 640x960 (Retina)
iPhone 5/iPod Touch 5 vertical screen 640x1136 (Retina)
Add Smart App Banner Smart App Banner (iOS 6 Safari)
The corresponding image size for iPhone 6 is 750×1294, and the corresponding image size for iPhone 6 Plus is 1242×2148.
Windows 8
Windows 8 tile color
Windows 8 tile icon
RSS subscription
favicon icon
For a more detailed introduction to favicon, please refer to https://github.com/audreyr/favicon-cheat-sheet
Mobile meta
XML/HTML CodeCopy content to clipboard
This is a summary of sharing from toobug.
More meta tag references
Reference article: