This site is designed for accessibility. Content is obtainable and functional to any browser or Internet device. This site's full visual experience is available in a graphical browser that supports web standards. Please consider upgrading your web browser.

DocTypes and Browser Questions

My Questions:

  1. Can we rely on browser makers to be consistent in their implementation of which doctypes trigger standards mode which doctypes trigger quirks mode? And if not how do we deal with it? Tracking which doctypes trigger which modes in all browsers will certainly help.
  2. Will it ever come down to a dilemma of picking a DOCTYPE string value that is both a correct description of the DTD and that also triggers the desired "quirks" or "strict" mode. May ensuring correct rendering, mean you may end up needing a DOCTYPE declaration that conflicts with the actual structure of a document? Fortunately it seems that the browser doesn't actually use the DOCTYPE to validate the content -- it only uses this string to toggle specific behavior of the renderer. This would be a particularly difficult thing to accept -- that we may have to lie about the type of HTML/XHTML document to obtain the desired rendering.

Answer from Eric A Meyer:

"We can rely on browser makers to be more consistent than they have been in the past-- but as you can see from the charts, pure consistency still eludes us. There may be cases where you have to choose the DOCTYPE carefully, but there should never be a case where you have to lie. Here is my advice: If you want "standards" mode, then pick the appropriate Strict DOCTYPE and make sure your markup validates. If you want "quirks" mode, do not include any DOCTYPE at all, and make sure your markup is valid. This is especially true of XHTML, because all XHTML DOCTYPEs trigger "standards" mode. If you are authoring in XHTML but for some reason want browsers to use "quirks" to render the document, then leave off the DOCTYPE completely. "

Good advise...the only problem I can see with using this method is...If you want "quirks" mode AND do not include any doctype AND you want it to pass the W3C Validator. Even though your markup is valid, the W3C Validator will choke on the document.
--LLC