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?
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.
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.