htmlbrowserquirks-mode

How to tell if a browser is in "quirks" mode?


Let's suppose you have a page with a relatively strict doctype and HTML markup that's pretty close to compliant, but perhaps misses in a few silly ways, perhaps because of user content that's out of your control... say you're working on a content management system or a theme for a content management system where you control some basic structure and need some javascript, but you're not responsible for everything else that goes into pages.

How can you tell (or: what will determine) when the browser decides to go into "quirks" mode rather than use it's more standards compliant engine?

I'm looking for answers for each of the major browsers, since IE, Chrome, Safari, and Firefox will of course all handle that differently. Is one single error enough to force it or do you have some leeway?


Solution

  • In Firefox and Opera you can determine if your browser is in "quirks mode" by checking page info.

    Using document.compatMode, will tell you the mode you are in with most browsers.

    In Chrome, Safari, and IE, run this javascript in the address bar:

     javascript:window.alert('You are in ' + (document.compatMode==='CSS1Compat'?'Standards':'Quirks') + ' mode.')
    

    (note that you'll need to re-type the javascript: portion after pasting into your address bar, due to recent security changes)