Detailed introduction to HTML head tag
This article is based on Yisi's article, and provides an expanded summary to introduce the meaning and usage scenarios of each tag and element in commonly used heads.
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 informs the browser Which HTML or XHTML specification does the server document use?
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), + means yes, - means no. Organization is the name of the organization, such as: W3C. The type is usually DTD. A tag is a designated public text description, 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
##XML/HTML Code Copy content to clipboard
- >
XML/HTML CodeCopy content to clipboard
- ##>
##●HTML 4.01 Frameset
##XML/HTML Code
>
●The latest HTML5 introduces more concise writing. It is forward and backward compatible and is recommended for use.
Copy content to clipboard
>
-
doctype has two main purposes in HTML.
●Verify the validity of documents.
●Weird mode
●Partially weird (nearly standard) mode About the document mode, browser mode, and strict mode ofIE browser
, weird mode, DOCTYPE tag, verbose mode? standard! Content. Declare the character encoding used in the document,XML/HTML Code
Copy content to clipboard
<meta charset="utf-8">
html5 The previous web page would have written like this:
##XML/HTML CodeCopy Content to clipboard
- ##<
meta http-equiv="Content- Type" content="text/html; charset=utf-8">
These two are equivalent. You can read the details step by step: vs , so it is recommended to use the shorter one, which is easier to use. memory.
lang attribute
Simplified Chinese
##XML/HTML Code
Copy content to clipboard
##<- html
lang=" zh-cmn-Hans"> Traditional Chinese##XML /HTML Code
Copy content to clipboard<
- html
-
lang="zh-cmn-Hant">## Why lang="zh-cmn-Hans" instead of what we usually write As for lang="zh-CN", please read further: The statement at the head of the page should be lang="zh" or lang="zh-cn". Use the latest version of IE and Chrome first
XML/HTML CodeCopy content to clipboard
##<meta
- http-equiv
- =
"X-UA-Compatible" content="IE=edge,chrome=1" /> 360 Using Google Chrome Frame
XML/HTML CodeCopy content to clipboard##< ;meta
name- =
- "renderer"
content="webkit"> 360 browser will immediately switch to the corresponding speed core after reading this tag. Also add
XML/HTML Code
to be on the safe side
<meta
http-equiv- =
- "X-UA-Compatible"
content= "IE=Edge,chrome=1">## The effect that can be achieved by writing this way is that if Google Chrome Frame is installed, then Use GCF to render the page. If GCF is not installed, use the highest version of the IE kernel for rendering. Related links: Browser kernel control Meta tag documentation Baidu prohibits transcoding
When you open a webpage through Baidu mobile phone, Baidu may transcode your webpage , take off your clothes, and put an advertisement for dog skin plaster on your body. To do this, you can add
##XML/HTML Code## in the head
#Copy content to clipboard<meta http-equiv="Cache-Control" content="no-siteapp" />
SEO optimization part
Page titletag (head header is required)
##XML/HTML CodeCopy content to clipboard
- ##<
title>your titletitle>##Page keywordskeywords
##XML/HTML Code
Copy content to clipboard<
- meta
-
name="keywords" content="your keywords">Page description content description
## XML/HTML CodeCopy content to clipboard
<
meta- name
="description" content="your description"> Define web page author author
##XML/HTML Code
Copy content to clipboard<meta
- name
- =
"author" content="author ,email address"> Define the web search engine indexing method, robotterms is a set of values separated by English commas ",", usually there are The following values are available: none, noindex, nofollow, all, index and follow. XML/HTML Code
Copy content to clipboard
# #<meta
name
- =
- "robots"
content="index,follow">Related links: WEB1038 - Tag contains an invalid valueviewport
Viewport can make the layout display better on mobile browsers. Usually write
Copy the content to the clipboard
##XML/HTML Code<meta name
=- "viewport"
-
content="width=device-width , initial-scale=1.0">##width=device-width will cause the iPhone 5 to open the page in WebApp full-screen mode after adding it to the home screen Black edges appear (http://bigc.at/ios-webapp-viewport-meta.orz)content Parameters: width viewport width (value/device-width) height viewport height (value/device-height)initial-scale initial scaling ratio
maximum-scale maximum scaling ratiominimum-scale minimum scaling ratiouser-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 loads. This is a Boolean value and can be written directly like this:
XML/HTML CodeCopy content to clipboard
##<meta name="viewport" content="width=device-width, initial-scale=1, minimal-ui">
XML/HTML CodeCopy content to clipboard
<meta name="viewport" content="width=device-width,user- scalable=yes">
Suitable for iPhone 6 and iPhone 6plus then Need to write:
XML/HTML Code
Copy content to clipboard<meta name="viewport" content="width=375">
<meta name="viewport " content="width=414">
##Mostly 4.7~5 inches The viewport width of Android devices is set to 360px, but it is 375px on iPhone 6. The viewport width of most 5.5-inch Android machines (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)
XML/HTML CodeCopy content to clipboard
- <
meta name="apple-mobile-web-app-title" content="Title"> < !-- Title added to the home screen (new in iOS 6) -->
XML/HTML CodeCopy content to clipboard
- ##<
meta name="apple-mobile-web-app-capable" content="yes" /> ##Set the background color of the status bar
XML/HTML Code
Copy content to clipboard<
- meta
name="apple-mobile-web-app-status-bar-style" content="black- translucent" />
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 page 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##XML/HTML CodeCopy content To clipboard
- ##<
meta name="format-detection" content="telephone=no" />
iOS icon
rel parameter: apple-touch-icon
Pictureis 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, must have the code as follows:
iPad, 72x72 pixels, optional, but recommendedThe code is as follows:
Retina iPhone and Retina iTouch, 114x114 pixels, optional, but recommendedThe code is as follows:
Retina iPad, 144x144 pixels, optional, but recommendedThe code is as follows :
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 thiscode as follows:
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 startup screen of iPad is Excluding the status bar area.
iPad portrait screen 768 x 1004 (standard resolution)The code is as follows:
iPad vertical screen 1536x2008 ( RetinaThe code is as follows:
iPad landscape screen 1024x748 (standard resolution)The code is as follows:
< ;link rel="apple-touch-startup-image" sizes="1024x748" href="/Default-Portrait-1024x748.png" />
The startup screen of iPhone and iPod touch includes Status bar area.iPhone/iPod Touch portrait screen 320x480 (standard resolution)
The code is as follows:
iPhone 5/iPod Touch 5 vertical screen 640x1136 (Retina)
The code is as follows:
Add Smart App Smart App Banner (iOS 6+ Safari)
The code is as follows:
The corresponding image size for iPhone 6 is 750×1294, and for iPhone 6 Plus The corresponding value is 1242×2148.
The code is as follows:
Windows 8
Windows 8 tile colorThe code is as follows:
Windows 8 tile icon
code is as follows:
rss subscription
The code is as follows:
< link rel="alternate" type="application/rss+xml" title="RSS" href="/rss.xml" />
favicon icon
The code is as follows:
For a more detailed introduction to favicon, please refer to https://github.com/audreyr/favicon-cheat-sheet
Mobile version meta
XML/HTML CodeCopy content to clipboard##<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable= no" />
- ##<
meta name="apple-mobile-web-app-capable" content="yes" />
- <
meta name="apple-mobile-web-app-status-bar-style" content="black" />
##< meta name="format-detection"content="telephone=no, email= no" />##<
- meta
name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
<meta name="apple-mobile-web-app-capable" content="yes" />
##<meta name="apple-mobile-web-app-status-bar- style" content="black" />
- ##<
meta name="format-detection" content="telphone=no, email=no" />
<meta name="renderer" content="webkit ">##
- meta
http-equiv="X-UA-Compatible" content="IE=edge">#
##<
meta- name
="HandheldFriendly" content="true">
name##<meta
- =
"MobileOptimized" content="320">
- ##<
=meta
name- "screen-orientation"
##<content="portrait">
"x5-orientation"meta name
=content="portrait">##<
- meta
name=
"full-screen"- content
="yes"><
- meta
name=
"x5-fullscreen"- content
="true">
<meta name="browsermode" content="application">
<meta name="x5-page-mode" content="app">
##
- ##<
##meta name="msapplication-tap-highlight" content="no">
Hot AI Tools
Undresser.AI Undress
AI-powered app for creating realistic nude photos
AI Clothes Remover
Online AI tool for removing clothes from photos.
Undress AI Tool
Undress images for free
Clothoff.io
AI clothes remover
Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!
Hot Article
Assassin's Creed Shadows: Seashell Riddle Solution1 months ago By DDDWhat's New in Windows 11 KB5054979 & How to Fix Update Issues3 weeks ago By DDDWhere to find the Crane Control Keycard in Atomfall1 months ago By DDDHow to fix KB5055523 fails to install in Windows 11?2 weeks ago By DDDInZoi: How To Apply To School And University3 weeks ago By DDDHot Tools
Notepad++7.3.1
Easy-to-use and free code editor
SublimeText3 Chinese version
Chinese version, very easy to use
Zend Studio 13.0.1
Powerful PHP integrated development environment
Dreamweaver CS6
Visual web development tools
SublimeText3 Mac version
God-level code editing software (SublimeText3)
Hot Topics
-
- "robots"
- =
- name
- "renderer"
- =
-

Guide to Table Border in HTML. Here we discuss multiple ways for defining table-border with examples of the Table Border in HTML.

This is a guide to Nested Table in HTML. Here we discuss how to create a table within the table along with the respective examples.

Guide to HTML margin-left. Here we discuss a brief overview on HTML margin-left and its Examples along with its Code Implementation.

Guide to HTML Table Layout. Here we discuss the Values of HTML Table Layout along with the examples and outputs n detail.

Guide to HTML Input Placeholder. Here we discuss the Examples of HTML Input Placeholder along with the codes and outputs.

Guide to the HTML Ordered List. Here we also discuss introduction of HTML Ordered list and types along with their example respectively

Guide to Moving Text in HTML. Here we discuss an introduction, how marquee tag work with syntax and examples to implement.

Guide to HTML onclick Button. Here we discuss their introduction, working, examples and onclick Event in various events respectively.
