Page upgrade -- now with blog-like goodness
Yup... I fixed a few bugs in the site code. First, I noticed that robots are traversing my site, and screwing up the metrics I'm taking, so I added a robots.txt. I'm not expecting this to work as some shady organizations ignore the settings of this file, but it should cut down on some unneccesary traffic. Second, after reading this article, I realized that though my documents all parsed as valid XHTML 1.1, the benefits of such are nil unless I actually have the HTTP server pass the document to XML-aware browsers as MIME-type "application/xhtml+xml". Instead, apache was sending it as "text/html", which made tells the browser to look at the document as "tag soup", and tolerate all kinds of quirks in CSS and non-well-formedness.
Well, the problem is further complicated by Internet Explorer... not a single version knows how to deal with XML content. Luckily, user agents (in this case, browsers) publish what type of content they accept. Firefox, for instance, publishes "application/xhtml+xml" as one of the options in its HTTP-ACCEPT header. So I have a little bit of PHP code that snifs to see if the UA accepts what we want to publish:
if( stristr( $_SERVER["HTTP_ACCEPT"], "application/xhtml+xml" ) )
{
header( "Content-type: application/xhtml+xml" );
}
else
{
header( "Content-type: text/html" );
}
This basically sees if the UA accepts XHTML, and if so sends that MIME-type. Otherwise, it sends "text/html". So both classifications of browsers (those made by Microsoft, and those made by anyone else). So everybody is happy. I think.
Immediately after I did this, I tested it in multiple browsers and lo, it did
render different. It handles the coloration of margins differently, and there
was a white border on the top and bottm of the page, where the grayish
background should have been. It turns out that I needed to apply the background
color to the <html>
element rather than the <body>
element in the style
sheet. One line of code difference, and it rendered perfect. I have to say:
damn, I'm good! It rendered near identical using alternatively a legacy
SGML parser and a modern
XML parser. Life is, in fact, good.