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
Table of contents 1. Introduction 2. Implementati...
Table of contents 1. Date 2. RegExp 3. Original p...
In enterprises, database high availability has al...
question Recently I encountered a requirement to ...
1. Download the installation package from the off...
Preface Before, I used cache to highlight the rou...
Copy code The code is as follows: <style type=...
Table of contents First method App.vue Home.vue H...
mktemp Create temporary files or directories in a...
I finally finished the project at hand, and the m...
MySQL software installation and database basics a...
ins and del were introduced in HTML 4.0 to help au...
Table of contents 1. Preprocessing 2. Compilation...
Directly code: select 'bigint unsigned' a...
Related reading: MySQL8.0.20 installation tutoria...