XHtml DocType or DTD – level 200

Especially as we move to ASP.NET 2.0, it’s important to use an XHtml DocType or DTD.  ASP.NET 2.0 server controls will render valid XHtml transitional markup, so that’s the most compelling Doctype, and that’s the one I prefer, but pick one of the following:

  • XHtml 1.0 Transitional

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

  • XHtml 1.0 Frameset (if you need to use <iframe />

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

  • XHtml 1.0 Strict

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

The DocType needs to be the first line in the page; however, since XHtml is valid Xml, you can optionally add an Xml declaration at the top:

<?xml version=”1.0″?>

And if you do this, the Xml declaration has to first, and then the DocType would come directly after.