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 doctypeThe doctype tag is used to specify the document's dtd(Document Type Definition), written at the front of each html, as shown in:
<!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 doWhether or not specifying doctype, and specifying different doctypes will activate different browser modes, thus creating some impact on html, css and js, the most famous of which is the so-called box model problem.
2.1 Why are there multiple modes
In a long time ago, when netscape and IE were competing for the world, because they were too powerful, the browser mode was decided by the browser itself. Time passed, and in the blink of an eye, the era of heroes in the Warring States Period was coming. Everyone found that if they had the final say, the world would be in chaos. They discussed and recommended a leader, so W3c came to power. But the problem arises again. For example, IE, although it is no longer the only way to be the norm, it is the general trend to align with the standards, if the browser only supports the standards, many previous pages will have some 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, the standard is followed, which is called standard mode or strict mode (Standards Mode). During this period, several people represented by Mozilla felt that the analysis of standard modes such as img was not very suitable, so they retained some personal opinions. When specifying some specific doctypes, a quasi-standard mode will be adopted. For details, please refer to Activating Browser Modes with Doctype, or @在官网官网官网官网官网官网官网官网官网官网官网官网官网官网官网官网官网官网官网官网官网官网官网官网官网官网官网官网官网官网官网官网官网官网官网官网官网官网官网官网官网官网官网官网官网官网官网官网官网官网官网官网官网官网官网官网官网官网官网官网官网官网官网官网官网官网官网官网官网官网官网�
2.2 Specific impacts of different modes
@ppk Daniu has already made a good summary for us, Quirks mode and strict mode.
3. The recommended doctype<!DOCTYPE HTML>
Reason: Support html5, and if it is not recognized, it will adopt strict mode.
Add some reset css, such as img { display: block } to solve browser compatibility problems.
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 quirk mode in several major browsers. In other words, they can be added without adding it.