Use XHTML for your web applications, please! – level 100

I realize that a lot of web applications are targeted for IE, and it may be an intranet application.  Even so, it pays to put the line:

<!DOCTYPE html
PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN”

Adding this will save you so much grief later on.   First, your CSS will actually cascade down to child elements, so you can have a very clean stylesheet.  Second, you know that your site will render properly in all browsers.  No need to test all the browsers.  By making your pages XHTML, you are adhering to the standard, so that’s all you need to worry about. 

The alternative is to muck up your stylesheet with duplicate declarations and the same css class on nested elements.  Then, when the site looks good, just open it in another standards-based browser and cry.

Many people don’t know that if you fail to put a doctype at the top of a page, IE will interpret it as HTML4.0.  If you want HTML4.0, then at least put the doctype there:

Even then, the other browsers (that default to XHTML) will see the doctype and interpret it as HTML4.


I wonder how many web application developers out there have never read the standards docs for xhtml or css. . .