HTML And XHTML Doctypes

23rd June 2008

In order to validate any page of HTML or XHTML you will need a doctype. This is a string of text that sits at the top of the document and tells the browser exactly what markup standard has been used to create the page.

XHTML Strict

This doctype is used in an XHTML document when you are not using any framset or depreciated tags.

  1. XHTML Transitional
  2. This doctype is used if your XHTML document contains depreciated tags like <b>.
  3.  
  4. XHTML Frameset
  5. Use this XHTML doctype if your document contains either frameset tags or depreciated tags, or both.
  6.  
  7.  
  8. HTML Strict
  9. Use this HTML doctype if your document contains no depreciated tags.
  10.  
  11.  
  12. HTML Transitional
  13. Also called loose, this doctype is to be used if your HTML document contains depreciated tags.
  14.  
  15.  
  16. HTML Frameset
  17. This doctype is used in a HTML document that contains frameset tags or depreciated tags or both.
  18.  
  19.  
  20. Without these doctypes in place the browser will default to what is called "quirks mode" where certain CSS styles are looked at a little differently. If you are finding trouble with your stylesheet then try adding a doctype that fits your markup.
  21.  
  22. Alternatively, if you find that you want your page to validate and adding the doctype tag actually destroys the page then you can add what is called a "broken doctype". This is the same as any normal doctype, but with the URL pointing to the DTD missing. Here are two examples.
  23.  
  24. XHTML Strict Broken Doctype
  25. This doctype is used in an XHTML document when you are not using any framset or depreciated tags, but still want the page to display in quirks mode and validate properly.
  26.  
  27.  
  28. HTML Strict Broken Doctype
  29. This doctype is used in an HTML document when you are not using any framset or depreciated tags, but still want the page to display in quirks mode and validate properly.

Add new comment

The content of this field is kept private and will not be shown publicly.