Analysis of the Neglected DOCTYPE Description

Analysis of the Neglected DOCTYPE Description
doctype is one of them:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
1. What is doctype? The doctype tag is used to specify the document's dtd (Document Type Definition) and is written at the beginning of each HTML, as follows:
<!DOCTYPE RootElement Availability "URI" [declarations]>
Such as several common doctypes:
HTML 4.01: Strict<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
HTML 4.01 Transitional<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
XHTML 1.1 Strict DTD<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2. What can doctype do? <br />Whether or not doctype is specified, or different doctypes are specified, different browser modes will be activated, which will have some impacts on HTML, CSS and JS. The most famous of these is the so-called box model problem.
2.1 Why are there multiple modes? A long time ago, when Netscape and IE were competing for supremacy, the browser mode was decided by the browser itself because they were too powerful. Time passed, and in the blink of an eye it was the era of the Warring States. Everyone realized that if they all had the final say, the world would be in chaos, so they discussed electing a leader, and so w3c came to power. But the problem arises again. For example, IE can no longer dominate the market and it is a general trend to align with standards. However, if the browser only supports standards, many previous pages will have problems.
So doctype came into being. If no doctype is specified, the original mode is adopted, which is called Quirks Mode. If doctype is specified, it follows the standard, which is called Standards Mode. During this period, several people, represented by Mozilla, felt that the parsing of img in the standard mode was not very appropriate, so they retained some personal opinions. When specifying some specific doctypes, an almost standard mode (Almost Standards Mode) will be adopted. For specific details, please refer to Activating Browser Modes with Doctype, or @随网之舞's translation to activate browser mode with doctype.
2.2 The specific impact of different modes @ppk has given us a good summary, Quirks mode and strict mode.
3. Recommended doctype
<!DOCTYPE HTML>
Reason: Support HTML5. If it is not recognized, strict mode will be used.
Add some reset CSS, such as img { display: block } to solve browser compatibility issues.
It should be noted that the <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> and <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> used by many people now are only equivalent to quirks mode in several major browsers. In other words, they can be omitted.

<<:  Some tips on website design

>>:  Summary of Several Methods for Implementing Vertical Centering with CSS

Recommend

Web Standard Application: Redesign of Tencent QQ Home Page

Tencent QQ’s homepage has been redesigned, and Web...

Detailed explanation of storage engine in MySQL

MySQL storage engine overview What is a storage e...

MySQL 5.7.21 Installer Installation Graphic Tutorial under Windows 10

Install MySQL and keep a note. I don’t know if it...

Complete steps of centos cloning linux virtual machine sharing

Preface When a Linux is fully set up, you can use...

my.cnf (my.ini) important parameter optimization configuration instructions

MyISAM storage engine The MyISAM storage engine i...

Detailed Example of Row-Level Locking in MySQL

Preface Locks are synchronization mechanisms used...

Detailed explanation of meta tags (the role of meta tags)

No matter how wonderful your personal website is,...

Detailed explanation of the use of vue-resource interceptors

Preface Interceptor In some modern front-end fram...

mysql5.7.18.zip Installation-free version configuration tutorial (windows)

This is the installation tutorial of mysql5.7.18....

Detailed explanation of MySQL backup and recovery practice of mysqlbackup

1. Introduction to mysqlbackup mysqlbackup is the...

Guide to using env in vue cli

Table of contents Preface Introduction-Official E...

Use of MySQL SHOW STATUS statement

To do MySQL performance adjustment and service st...