[thelist] Confused - how does all this fit together ?

Peter-Paul Koch pp.koch at gmail.com
Fri Dec 3 17:18:28 CST 2004


> this is my first post to this list - so please, be
> gentle. I have been reading for a week now about all
> kinds of User Agents being able to render all kinds of
> documents (HTML tag soup, HTML4, XHTML1.x, ..) as
> specified by MIME types, document sniffing, file
> extensions, etc.

Secretly the browsers treat all HTML and XHTML flavours the same,
unless you actually serve an xhtml document with mime type
application/xhtml+xml (which in turn doesn't work in IE Win). So for
rendering purposes (as opposed to validation purposes) the exact
flavour doesn't matter.

> 1. - All webpages are rendered by User Agents that
> always provide either a 'window' or a 'frame' object
> to be used as a container for the webpage. This object
> always contains the 'document' object which represents
> the webpage to be rendered.

A frame object is really a window, except that in a frameset a browser
shows several windows next to each other.

The window object also serves as the global object for JavaScript.

> 2. - The document rendered is considered to be of a
> certain document type which depends on the MIME type
> (if the document was served by a webserver), or the
> file extension (if the document resides on a
> filesystem), and/or the DOCTYPE declaration at the top
> of the 

The DOCTYPE is only there for the validators, and to trigger Strict
CSS Mode. For all practical purposes it doesn't tell the browser what
to do with the document (except for CSS Strict Mode).

> 3. - The document to be rendered can be accessed using
> the appropriate DOM Level. Which DOM Level is
> appropriate depends on the document type.

No. Each document can be accessed by any DOM level. The various levels
only denote extensions to the original Level 1 DOM, which contains the
basics. For most Web purposes Level 1 contains plenty of
functionality.

The document type has little to do with the DOM, except that the
browser somehow has to handle malformed HTML (like <p>This is
<b>bold</p>.</b>) Exactly how they handle it is still an open
question, and the answer will likely vary from browser to browser.

> 4. - The rendering process can be influenced by the
> use of CSS stylesheets. Depending on the document type
> there are slight differences to be considered.

No. Depending on Strict or Quirks Mode there are differences to be
considered. Currently the Modes are indeed triggered by doctypes, but
in theory they could be triggered by something else. Also, there are a
few doctypes that trigger Strict Mode in one browser and Quirks Mode
in another.

And the REAL differences are of course the differences in
interpretation of the standards by the various browsers.
 
> 5. - Each 'window' or 'frame' is associated with it's
> own Global JavaScript object which can hold multiple
> XML DOM objects (created by
> document.implementation.createDocument()).
>   Note: I am not really sure what controls which of
> the documents is being rendered.

Dunno about the multiple objects. For Web purposes it doesn't really
matter. Each window holds one document, which is plenty to keep
everybody happy.

As to your code example, my Mozilla gives '1' for the length of the
body collection, as it should.

> Based on these assumptions I tried to start with a
> simple document of the strictest type:
> 
> -test.xhtml-------------------------------------------
> 
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
> "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
> <html xmlns="http://www.w3.org/1999/xhtml"
> xml:lang="en"><head><title>xdom</title><script
> type="text/javascript" src="xdom.js"></script>
> <link rel="stylesheet" type="text/css"
> href="test.css"></link></head><body>&#xa0;</body></html>
> 
> -xdom.js--------------------------------------------
> 
> function js_main(){
> alert(document.getElementsByTagName('body').length);
> }
> window.onload=js_main;
> 
> -----------------------------------------------------
> 



-- 
-------------------------------------------------------------------
ppk, freelance web developer

NEW: Bug Report system:
Report bugs yourself, or comment on previously 
reported ones.
http://www.quirksmode.org/bugreports/
------------------------------------------------------------------


More information about the thelist mailing list