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.
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".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. ...
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:
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?... '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.
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,
CirTap