The annoying XML prolog (in standard templates) and its impact on the CSS

User avatar
Joomla! Explorer
Joomla! Explorer
Posts: 418
Joined: Mon Dec 12, 2005 5:34 pm

The annoying XML prolog (in standard templates) and its impact on the CSS

Post by CirTap » Wed Oct 18, 2006 4:46 pm


I was always wondering why the default templates contain an XML prolog? There is no rational to include this line and it causes more harm (and work) than doing good.
It harms because due to a misbehaving feature (aka bug) in MSIE 6, if the prolog is provided, this browser switches into the behated "compatibility mode", or "quirks mode" as others call it.
It even requires an extra line of PHP code to bypass its issue with the "<?" character sequence.

In order for MSIE 6 to use the "standards/strict mode" for the CSS 2.1+ box-model like Opera, Firefox, Safari, and most others compliant browsers, the first line of the document must contain a full-qualified DOCTYPE. If these requirements are met, a CSS 2.1 compliant style sheet usually require no or much less "hacks". Minor tweaks can go into validating, MSIE-verson specific conditional comments.
This allows for writing valid and less CSS code as well.

None of the recent browsers, incl. the yet-to-be-released-MSIE7, behaves any different if the XMP prolog is ommited, as long as a full-qualified (X/HTML) DOCTYPE is given. In IE7, however, the bug ...err, feature... was finally fixed, but it will still take a while until all Windows desktops are updated.
W3C: Normative Definition of XHTML wrote:An XML declaration is not required in all XML documents; however XHTML document authors are strongly encouraged to use XML declarations in all their documents. Such a declaration is required when the character encoding of the document is other than the default UTF-8 or UTF-16 and no encoding was determined by a higher-level protocol. ...
Since by definition, a document sent with "text/html" is not considered an XML document, the prolog can be safely ommited -- even with a DOCTYPE of XHTML-Strict. The "higher-level" protocol in our case are the HTTP response headers sent from Apache/PHP/Joomla! and include the required "Content-Type: text/html" and "Encoding: UTF-8".
Now, since the "higher-level protocol" provides the encoding for us (it also did in J! 1.0.x) the prolog has never been neccessary as all. It SHOULD be present if, and only if, the document is sent with an XML mime-type such as "application/xhtml+xml" or any of the generic text/xml, application/xml.
Joomla (PHP) gives us "text/html", which is perfectly valid and appropriate for XHTML documents, esp. if it's "Transitional".

The document "XHTML Media Types" sums it up:
...  'application/xhtml+xml' SHOULD be used for XHTML Family documents, and the use of 'text/html' SHOULD be limited to HTML-compatible XHTML 1.0 documents. 'application/xml' and 'text/xml' MAY also be used, but whenever appropriate, 'application/xhtml+xml' SHOULD be used rather than those generic XML media types.
Since "should" doesn't mean "must", and our J!-generated web pages -- HTML documents -- come as text/html and encoded in UTF-8 anyway, why this prolog?

An attempt to use 'application/xhtml+xml', as the document suggests, would not be appropriate in the case of Joomla! or any regular web page for several reasons:
- if both this mime type and the prolog are present, recent Geckos (Netscape, Mozilla, Firefox) will begin to validate the document against the DTD given in the DOCTYPE
- MSIE can't handle "application/xhtml+xml" by default and wants to download the document.

I doubt anyone wants any of this to happen on a live site, not mentioning that it's almost impossible to guarantee the page and its content are 100% valid XML.

Just in case anyone wants to propose I should just remove it from my templates, well, guess what ...

If there'll be no discussion following this post, it may hopefulle help some CSS novices to find the #1 reason why their perfectly valid style sheets fail to render correctly in Internet Explorer 6 only. It won't solve all the trouble, but a pretty damn lot.
Please drop that XML prolog from the standard template(s) to prevent people from copying this (imho) bad practice, and simplify their lifes if it comes to CSS.

Thanx for reading, and have fun,
You can have programs written fast, well, and cheap, but you only get to pick 2 ...

"I love deadlines. I like the whooshing sound they make as they fly by." Douglas Adams

User avatar
Joomla! Ace
Joomla! Ace
Posts: 1347
Joined: Fri Aug 26, 2005 1:31 am

Re: The annoying XML prolog (in standard templates) and its impact on the CSS

Post by compass » Mon Oct 23, 2006 3:31 am

The thing is, not many designers understand doctype and its implications....
I especially like this observation from, [information on W3C's site about doctypes is] "written by geeks for geeks. And when I say geeks, I don’t mean ordinary web professionals like you and me. I mean geeks who make the rest of us look like Grandma on the first day She’s Got Mail.™".
You are right though, correct header syntax should used.
Follow me on Twitter @compassdesign - Get get free templates and news for Joomla - Fully Managed Joomla Hosting - Unlimited Support


Return to “Design and Accessibility - Archived”