|
Posted by David Dorward on February 6, 2006, 2:35 pm
Please log in for more thread options
wardy wrote:
> I'm trying to undestand the impact of using content negotiation when
> rendering my Web pages to various different browsers as I would like to
> use the XHTML Strict DOCTYPE declaration. Reading the W3C guidelines,
> if I render as 'text/html' then there are some backward compatibility
> issues I need to worry about.
If you serve as text/html then some browsers will render the document in
ways you don't like (splattering the page with ">" characters whereever you
have an <img />, <br />, <hr /> and so on).
> Does this mean that the page must be rendered in one way if I use the
> "application/xhmlt+xml" content type and another if I use the "text/html"
> content type?
If it is served as text/html then it will be parsed with a tag soup slurper.
If it is served as application/xhtml+xml then it will be parsed with an XML
parser (which means IE will prompt user's to download it, and Firefox won't
render it until the entire document is downloaded and parsed, and will spit
errors at the user instead of trying to recover if the document isn't well
formed).
There are no differences in how browsers are supposed to render XHTML and
HTML (although there /are/ rules as to how CSS is applied which could
influence the rendering (e.g. class selectors are HTML only and don't apply
to XHTML, and the root element is <html> instead of <body>).
> This would mean parsing of every page on the site....
Browsers have to parse every page they display.
> Or, if I follow the backward compatibility rules from the W3C, will it
> render properly regardless of the content-type for a particular request?
No. At present, unless you have need of something that only XHTML can
provide on the client (like mixed-namespace documents), stick to HTML. (By
all means _write_ XHTML, but transform it to HTML before it gets to the
client).
The Mozilla FAQ states that the only reason application/xhtml+xml has a
higher quality value than text/html in the Accept request header, is so
that the browser will get MathML versions of documents. They advise the use
of HTML 4.01 Strict.
--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/> Home is where the ~/.bashrc is
|