Appendix C, why hast thou forsaken me?

XHTML 1.0’s Appendix C is the bible for tag soup pretend XHTML (like what I produce: stop bristling, it’s true): it tells you how to produce XHTML which you can serve as text/html to browsers which don’t understand application/xhtml+xml, or, much more commonly, how to pretend that you are using XHTML for some hypothetical future benefit when you are actually just producing HTML with some extra slashes.

However, when I started looking at how far WordPress had strayed from being actual XHTML that could be served as application/xhtml+xml, the very third thing I found looks rather like a deal-breaker: WordPress 2.0 is going to have an editing interface to let you choose custom colors for that blue gradient header background you’ve seen a billion times behind the title of “Foo, Just another WordPress weblog.” The values for the colors are then passed in the query string of a background: url() CSS declaration, and since there’s an upper and a lower, that’s ?upper=33eeee&lower=4180b6.

Unfortunately, Appendix C’s take on that, because the contents of style and script in XHTML are #PCDATA, parsed character data where & is converted to &, while in HTML they are #CDATA, character data where character references are not converted to characters, is

Use external style sheets if your style sheet uses < or & or ]]> or --.

Hixie’s famous Sending XHTML as text/html Considered Harmful offers a less final, but also less palatable alternative:

<style type="text/css"><!--/*--><![CDATA[/*><!--*/

which I’ve heard doesn’t work correctly in some older versions of Opera, though I don’t know if that’s actually true. Even if it works perfectly in every browser, bleah. That’s awful, a cunning plan at best. Is it also the only alternative to recasting the entire operation so that the URL is hidden away in an external CSS file? That’s not a happy choice, since you can’t count on being able to write to the wp-content directory, but not having the URL with the colors in the query string means having an external CSS file that not only creates an image, but also does a database query. I’m starting to like my hide the whole thing from people doing application/xhtml+xml idea more all the time.


Comment by Justin #
2005-11-28 20:58:51

It seems like the most obvious solution is to use a single GET variable and then parse two variables out of its value to avoid using the amperand at all; e.g., ?range=33eeee-4180b6. One explode('-', $_GET['range']) in the PHP and you’re done.

Comment by Phil Ringnalda #
2005-11-28 21:10:45