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

js to achieve drag and drop sorting details

Table of contents 1. Introduction 2. Implementati...

Basic reference types of JavaScript advanced programming

Table of contents 1. Date 2. RegExp 3. Original p...

MySQL dual-master (master-master) architecture configuration solution

In enterprises, database high availability has al...

Two ways to implement text stroke in CSS3 (summary)

question Recently I encountered a requirement to ...

How to install Nginx in CentOS7 and configure automatic startup

1. Download the installation package from the off...

Solution to the routing highlighting problem of Vue components

Preface Before, I used cache to highlight the rou...

Understanding of CSS selector weight (personal test)

Copy code The code is as follows: <style type=...

Detailed explanation of non-parent-child component communication in Vue3

Table of contents First method App.vue Home.vue H...

Detailed explanation of mktemp, a basic Linux command

mktemp Create temporary files or directories in a...

How to implement mobile web page size adaptation

I finally finished the project at hand, and the m...

MySQL 8.0.15 installation graphic tutorial and database basics

MySQL software installation and database basics a...

Detailed explanation of using INS and DEL to mark document changes

ins and del were introduced in HTML 4.0 to help au...

Detailed explanation of gcc command usage under Linux system

Table of contents 1. Preprocessing 2. Compilation...

Detailed tutorial on installing MySQL 8.0.20 database on CentOS 7

Related reading: MySQL8.0.20 installation tutoria...