You’re happy and excited because of a hard work on your web page, seems, that you did everything as a pro. Despite you wrote good CSS and XHTML and used a right specification for DOM, your site looks like a rotten egg in any kind of browser. Do you know what is wrong? Probably, it’s hard to believe but the answer is a wrong DOCTYPE header.
You can easily specify the document type definition (DTD) with the help of a doctype element. Although there are several versions of HTML, the doctype is necessary for the browser to help it to understand what type of web page it is. You need to set in the first line of a code to avoid various browser confuses and to show it according to what kind of standard a web page should be displayed.
A DOCTYPE tag is a key point of a web page, moreover, your code and CSS won’t be validated without a DOCTYPE element. In case, you use an incomplete or an obsolete DOCTYPE tag, or do not use this tag at all, your browser will set a quirks mode, hence, your web page will be disassembled by the rules of a backward compatibility.
There are various kinds of DOCTYPE elements, and they differ depending on the language version you’re targeting.
Related terms: CSS, HTML, XHTML, DOM, DTD, quirks more.
References and further reading: