Skip navigation.

ASP.NET Adaptive Rendering and Validator ControlsAll recent postsMicrosoft.com Backstage

Standards or Quirks?

Composing a correct DOCTYPE declaration could be a daunting process (see DOCTYPE Switch Browser Comparison). Miss a fully-qualified URI and your browser starts doing something you didn't expect.

Can you tell by looking at a DOCTYPE declaration if you're triggering the Standards mode? Or is it still in Quirks? You can look up DOCTYPEs W3C or elsewhere, but a slight omission in the declaration leaves you to the mercy of the browser because it has it own logic of deciding what mode to switch to.

For example, Eric Meyer provided some in his article Picking a Rendering Mode. See how tricky it gets? Also, check out Mozilla's DOCTYPE sniffing. Now that's a can of worms, if you ask me.

A found a handy little script at Mozilla to help troubleshoot rendering modes. The same article, Mozilla's DOCTYPE sniffing, points to a page that utilizes the script.

<div>
The DOM says we are in
<script type="text/javascript">
    var mode = document.compatMode;
    var output= "<span>" + mode + "</span>";
    document.write(output);
</script>
mode.
</div>

Or you could shorten it for better readability:

<div>
The DOM says we are in
<script type="text/javascript">
    document.write (document.compatMode);
</script>
mode.
</div>

The output is pretty much the same across all modern browsers. In Standards mode IE6/Win, Netscape 6+/Mozilla and Opera return "CSS1Compat". In Quirks mode IE6/Win and Mozilla report "BackCompat", while Opera says "QuirksMode".

Comments

Comment permalink 1 Mike Hensley |
Here's a bookmarklet that will do this-

Mode Check

Emails and Notifications

Would you like to be notified when somebody responds to this post?  Would you like to have these comments emailed to you?

TrackBacks

Sorry, TrackBacks are not allowed.

Submit your comment

Please enter only text since all HTML tags except hyperlinks will be stripped. Hyperlinks will become live links. Any comments with flaming or offensive language will be deleted. Be courteous to other posters. Thank you.

Your name (required):
Your email (optional):
Your site's URL (optional):
Enter this number
Type in the number above:
Comment (required):