HTML follows certain rules. These rules are included in a Document Type Definition file, or as known as DTD. DTD is an XML document that explains which tags, attributes, or values are valid for a specific type of HTML. Each HTML version has a corresponding DTD. Now you might ask, "What does all this have to do with CSS?"
If you want all content in a web page to be displayed correctly and consistently on a web browser, you have to tell the web browser which version of HTML or XHTML you are using, including what the doctype declaration at the beginning of a web page means. This document type declaration is on the first line of the HTML file, not only defining the HTML version you are using (such as HTML 4.01 Transitional), but also points to the appropriate DTD file in the web page. When the document is declared incorrectly, you will cause most browsers to enter a warning state called Quirks Mode.
Quirks Mode is the method used by browser manufacturers to make their software run like browsers in circa 1999 (the era of Netscape 4 and Internet Explorer 5). If a modern browser encounters a web page that does not have the correct document type, it will think: "Well, this web page must have been written in an HTML editor very early and long ago. I have to pretend that I am a really old browser to display the web page, just like those buggy old browsers." That's why when there is no correct document type, you style cute web pages with CSS may not look like what it should be based on current standards. When you detect on your browser, accidentally browse your page in Quirks Mode, you may stop trying to fix display problems related to incorrect document types rather than improper use of HTML or CSS.
Attention: For more information about weird modes, please visit www.quirksmode.org/index.html?/css/quirksmode.html and http://hsivonen.iki.fi/doctype/.
Fortunately, getting the right document type is simple. All you need to know is which version of HTML you are using. Most likely, you have created a webpage with HTML 4. You may even have started using XHTML for your website (see page 5).
The most popular versions of HTML and XHTML are HTML 4.01 Transitional and XHTML 1.0 Transitional. These HTML types still allow you to use display tags, such as <font> tags, which also provide a transition from legacy HTML to new HTML: stricter HTML and XHTML
Label. While it's better not to use these tags, they still work in Transitional, so you can phase out these old-style tags based on your own situation. In strict versions of HTML and XHTML, some old-style tags don't work at all.
Note: Generally speaking, strict versions of HTML and XHTML do not accept tags and attributes that only make web pages show good results, such as <font> tags and centered attributes of a paragraph. They also do not accept some once popular attributes, such as the target attribute of a link - allowing you to open a link in a new window.
If you are using HTML 4.01 Transitional, type the following document type declaration at the beginning of each web page you create:
Sample code [www.CuoXIn.com]