While I’m perhaps no longer as much of a purist as I used to be, whenever I’m tasked with writing HTML, I usually go to great lengths to make sure that it is valid. For academic reasons beyond the scope of this artcle, my preferred DOCTYPE is still HTML 4.01 Transitional, and I almost always code – and validate my code – to that standard.
Having been doing a lot of WordPress work recently, however, I’ve discovered an annoying WordPress quirk that can make it difficult to produce valid HTML 4.01 Transitional code: the wp_head() method outputs markup formatted for XHTML, and thus, its output will register as invalid when validated against the HTML 4.01 Transitional DOCTYPE.
While building out the website for the Go Primal Fitness gym a while ago, I encountered a somewhat interesting problem. The design called for a different background image on the html element for each “section” of the site, where sections where determined based off of anchors present in the top-level navigation.
Now assigning differing background images to the various body elements of a website is easily (and frequently) done. The implementation usually looks something like this: