Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DOCTYPE and quirks mode or not?

Status
Not open for further replies.

phlembol

Technical User
Sep 11, 2007
2
US
I have been involved in a debate about how browsers handle errors and I am hoping someone can offer some enlightenment. Here's the deal:

The browser sniffs the DOCTYPE from the web page and then begins rendering in a mode based on the DOCTYPE as cross-referenced to the browser version.

(This is mutually accepted to this point I assume as there are plenty of tables stating that mode will be chosen based on DOCTYPE, browser, and browser version.)

The disputed claim adds:
The browser encounters an error during the render and switches to quirks mode at that point. (The claimant hasn't made it clear if the browser continues to render the rest of the document in quirks mode or if it switches to quirks mode for only the non-conforming code and then switches back.)

This implies necessarily that the browser does error checking during the render else it would not know an error.

There is zero mention at W3C.org, mozilla.org, msdn.com, or any other place I can find, that 1) error checking happens during the render or 2) that the browser will switch render modes after it starts rendering.

Can anyone answer this or point me to any supporting documents (for either side)? Thanks, phlembol
 
I cannot point you to any answers, but I can assure you that browser only checks the presence of a doctype (and in IE6 also the fact that the doctype is the first thing in the page) and the validity of the doctype and continues to render the document in a way it was determined based on the doctype. It does not change the rendering engine at any point during render.

If you do not believe me, there are easy ways to check. For instance, IE6 uses the wrong box model in quirks mode and a correct one in the standards mode. So, make a website with a complete and valid doctype, create one box (make sure you give it margins, borders, width and paddings in pixels), make an error and create a similar box. Then create another page without doctype. If what I say is correct, then both boxes on both pages will be the same size (although different sizes between documents). If your claimant is correct, the second box on the page with doctype will have different width.

___________________________________________________________
[small]Do something about world cancer today: PACT[/small]
 
My money is with Vragabond on this one. I'd be asking your 'claimant' for some proof that what he says is happening is actually happening (a screenshot with the full source code to reproduce the issue locally).

Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
I agree with both of you. Unfortunately, I find myself having to disprove the flawed advice of a "respected" member of the community. Since he has been there longer than I, and has been parroting the same advice for some time, it becomes his word against mine until I can prove him wrong.

His words quoted exactly: "Scenario: Browser reads the code but finds a couple of errors in a hit counter that it can't figure out. The page is error free otherwise, but the browser must switch to quirks mode in order to display this irregular syntax since there is no standard for it. Thus, you have a web page rendered in quirks mode because of a couple errors."

It is irrational to believe that such error-checking and mode-switching would NOT be documented some place.

I have pointed out that by using this JS call
javascript:alert(document.compatMode);
you can determine what mode the browser used in rendering. Then I constructed a minimal page using a full DOCTYPE of HTML4.01 Transitional and inserted FRAMESET tags which are not part of that standard. The browser rendered in compatMode of course. But (being the devils advocate here) if the browser were to use quirks mode for only the offending code, it could, theoretically, finish in Standards mode.

I am still looking for a simple, yet irrefutable, way to demonstrate his advise is flawed.

Thanks
 
That member might be right. We have little to no way of knowing what fuzzy logic browsers apply to render coding errors. But that would only involve errors. The rest of the page would go unaffected, so the fact that the page has a complete and valid doctype will still make it a standards-rendered page. That means that their comment is completely irrelevant to the discussion, as everything else on the page gets rendered in standards mode.

Finally, you can expand my test. Add an error (like align=center) to the second box and I am sure it will still get rendered in a standard way. I might even try and play with it a bit.

___________________________________________________________
[small]Do something about world cancer today: PACT[/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top