What is the purpose of DOCTYPE?
P粉779565855
P粉779565855 2024-01-28 22:15:26
0
2
464

I understand that the different document types are essentially about html compliance, but what difference does it make to the document type you specify? Will browsers handle the same code differently depending on document type? Thanks

Update - Most answers mention that weird mode can be turned off if the document type is not specified. But what is the difference between xhtml and html 4.01?

P粉779565855
P粉779565855

reply all(2)
P粉163465905

From Wikipedia:

I decided to quote this passage because it answers your question better than mine :). Importantly, missing DOCTYPE will trigger "weird mode" in some browsers.

P粉270891688

The most important thing is whether there is a document type. If you don't do this, the browser will work in "weird" mode instead of standard mode, and many things will be slightly different. If you have one (any of them), it usually activates more standards-compliant behavior in the browser.

See this article to learn more about the role of doctype in various browsers and the modes - quirks, standards, quasi-standards, etc. - that different browsers have. Quote the relevant part:

...but see the article for a full discussion.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!