How to ensure your web sites are valid Html (or XHtml) – level 300

I originally was going to label this post level 200, but given how few people know about Html standards, I’ve labeled it 300, but I don’t think this _should_ be an advanced topic.


The first easy step is to try to validate your site with a validator.  The one I use is from the W3C: http://validator.w3.org/.  Type in the site, and it will tell you what is wrong with it.  A series of events brought my focus back to this.  I’ve posted on this topics previously here, here, here, here, and here


I was setting some CSS overrides for my Community Server blog, and I wasn’t getting the results I wanted.  Then I inspected the page to find that the default skin of Community Server doesn’t set a DocType.  I was very surprised by this since Telligent has been on the ball on so many things.  Telligent’s own web site uses the XHtml 1.1 DocType, but it doesn’t validate.


Not including a DocType at all leaves the browser guessing as to what kind of markup your page is.  IE will assume Html 3.2 or (quirks mode).  FireFox wants to render it as Html 4.01 transitional.  In fact, if you use the default DocType in VS.Net 2003, you’ll be using an incomplete one that omits the location of the .dtd document.  You can write valid Html 4.0 this way (and I commend Microsoft for having a main page that correctly validates), but IE will still operate in quirks mode.  This may cause you some grief when laying out your pages because you will have unpredictable browser behavior.


Adhering to web standards greatly simplifies web application development when you need an attractive user interface.  There are some simple steps that even a beginning programmer can employ to ensure the web application is valid markup:



  • Add a DocType to the top of every page (or your master page in ASP.NET).  I recommend using:
    <!DOCTYPE html
    PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN”
    “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>

  • Validate your app with the W3C validator.

  • Fix every error it finds.

These simple steps can lead anyone to standards-compliant web application.