Home  >  Article  >  Web Front-end  >  Analysis of neglected DOCTYPE description_HTML/Xhtml_Web page production

Analysis of neglected DOCTYPE description_HTML/Xhtml_Web page production

WBOY
WBOYOriginal
2016-05-16 16:41:511224browse

Doctype is one of them:

1. What is doctype
The doctype tag is used to specify the dtd (Document Type Definition) of the document, written at the end of each html Front, in the shape of:
 vailability "URI" [declarations]>
Such as several common doctypes:
HTML 4.01: Strict
HTML 4.01 Transitional
XHTML 1.1 Strict DTD
2. What doctype can do
Whether or not doctype is specified, and specifying different doctypes will activate different browser modes, which will have some impact on html, css and js, among which The most famous is the so-called box model problem.
2.1 Why are there multiple modes
A long time ago, when Netscape and Internet Explorer were competing for dominance, the browser mode had the final say because it was too powerful. Time passed, and in a blink of an eye, it was the era of the Warring States Period. Everyone realized that if everyone had the final say, the world would be in chaos, so they discussed recommending a leader, and the w3c came to power. But the problem comes again. For example, IE, although it can no longer dominate and aligning with standards is the general trend, but if the browser only supports standards, many previous pages will cause some problems.
Then doctype came into being. If no doctype is specified, the original mode is used, which is called Quirks Mode. If doctype is specified, the standard is followed, which is called Standards Mode or Strict Mode. Mode). During this period, several people represented by Mozilla felt that the parsing of img in the standard mode was not very suitable, so they retained some personal opinions. When specifying some specific doctypes, an quasi-standards mode (Almost Standards Mode) would be adopted. , for specific information, please refer to Activating Browser Modes with Doctype, or @suiwangzhimei’s translation of Activating Browser Modes with Doctype.
2.2 The specific impact of different modes
@ppk Daniel has given us a good summary, Quirks mode and strict mode.
3. Recommended doctype
 
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 and used by many people now are only equivalent to quirks mode in several major browsers. In other words, they can be omitted.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn