A useful tip if you love both YouTube and markup validation

Not valid!YouTube is worlds apart from the likes of MySpace (*shudder*) when it comes to good code, but like most massively influential sites, they don’t really seem to care that much if their code validates, and even less if the code they provide webmasters for embedding content in their own sites does.

Frankly, I usually don’t care that much about validation either. I worked in this field for too many years when no validators even existed, and I’ve always taken the pragmatic approach: make it look and work the same, more or less, in all reasonably recent versions of Internet Explorer and Netscape (with Firefox and Safari having replaced Netscape over the past few years), and be done with it.

But I still have to admit that it’s a bit embarrassing that the “Valid XHTML” link (which appears in the Meta sidebar by default in WordPress) proves just how not valid my XHTML really is. I checked it today and was shocked to find 76 errors. I was relieved, however, when I dug in and discovered that only three of those errors had been my own. I had nested a <ul> inside a <span> (which I honestly didn’t even realize was a mistake, although I understand why it’s wrong, and it was easy enough to change from <span> to the valid <div> without any visible difference), and I had omitted alt attributes from a pair of images that don’t need to be identified by page readers anyway (and would probably be better off being worked into the CSS somehow).

These were pretty minor errors, if I do say so myself. 67 of the remaining 73 errors originated in cut-and-paste code blocks I got from PayPal and LinkShare (the latter of which I deal with only very reluctantly because they provide the mechanism for Apple’s iTunes affiliate program). What a surprise that the code from these sources looks like it was written by a tech support grunt in 1996 (in other words, by me in 1996)!

These were easy enough to fix, as well. I’ll just need to remember to fix them again if I ever change the code in those ad blocks, which I’m sure I will. The final 6 errors were the result of a YouTube video embedded in one of my blog posts. Ah yes, the age-old <object> vs. <embed> conundrum. I’ve always hated <object> because it seems unnecessarily complicated, with a slew of nested <param> tags that could just as easily have been attributes of the tag itself (although I suppose the point was to allow new parameters to be added without having to add support for new attributes in the DTD); plus it reeks of Microsoft’s platform-dependent ActiveX crapfest. I especially loathe the presence of, and need to hunt down, a ridiculously long, completely arbitrary clsid string representing the file format of the embedded file. (What’s wrong with a freakin’ MIME type?)

Unfortunately, the cleaner and more straightforward <embed> has never been part of any HTML specification, so it doesn’t validate.

Now it appears that there’s a solution to embedding YouTube videos in an XHTML-compliant way. Huzzah! But that means I’ll have to go back through all of my posts that have YouTube videos in them (which is a surprisingly large number) and fix them. It should be easy enough to hit them all at once with a well-constructed SQL query; I just need to study the pattern and do it. In fact, if I’d spent the last 15 minutes studying the problem instead of just complaining about it, I’d probably be done already.

But sometimes, complaining’s just more fun.

Reflections on Spring, in the Year 2003

Part I: The Fictionalized Account

Andy awoke with a start. His head was throbbing violently and his limbs were curled awkwardly about his abdomen. What had happened?

It must have been some kind of chemical attack. Andy, disoriented and in pain, struggled to his feet and surveyed the vast, empty landscape surrounding him. The harsh light from above made the entire world look like a blank, white void.

Andy spotted Carl a short distance away. He was lying, motionless, doubled-over. Andy moved as quickly as he could, struggling to coordinate his cloudy mind and malfunctioning legs.

Was Carl dead? There was no time to find out.

One thing was clear to Andy: survival depended on getting out of there, and fast. He tried but found himself too weakened by the chemicals coursing through his body to lift Carl, so as a last resort he fastened Carl to his leg and began to drag the heavy, motionless body behind him.

Andy spotted a large metallic object ahead, and determined it was their best chance for shelter. He made off in the direction of the object as quickly as he could in his present state, but just as he reached it, a huge, unfathomably strange arm reached out from above and lifted the object, moving it away and leaving Andy and Carl, once again, defenseless and exposed.

Part II: Wednesday Morning in the Kitchen

Spring has returned to the Atlanta area, and with it, the other inhabitants of our kitchen… ants.

It is fascinating to watch spring make its first tentative steps in February. Weeks of cold, drizzly days and frosted-over nights break abruptly with a balmy, sunny day. Almost invariably on such a day I will notice an ant or two has come to explore the kitchen countertop, but by nightfall the temperature dips below 32 degrees and the ants disappear again to wherever it is they go (assuming they are still alive at all).

And then, it hits. Suddenly, the nighttime lows are not below freezing anymore. I don’t arrive at my car in the morning to find a thin layer of frost to melt or scrape away. It’s not long before the crocuses, long-disappeared over the fall and winter, sprout once again from amidst the pine bark and bloom.

That’s when the throngs arrive. As abruptly as the crocuses reappear, so do the ants. Scores of them. Long queues of them marching across the countertop single-file. Until I finally just can’t take it anymore and I head to Kroger for some ant baits.

The baits I got this year are a different brand than I’ve used before. I can’t really tell if they’re less or more effective. Maybe they are more cruel and torturous than the old brand. Maybe they just weren’t meant to be placed on the countertops. All I know is, I have never seen the dead and dying, writhing ants under the effect of whatever’s inside those little black deathtraps before.

This morning I went to the kitchen to prepare my coffee, and I noticed a strange, sad, oddly compelling sight. One ant, apparently in some deal of pain itself, but still mobile, had somehow attached one of its deceased (or nearly so) brothers to its hind leg and almost appeared to be attempting to drag it to safety beneath the large metal cup-thing (what would you call that, anyway?) that we keep our cooking utensils in.

Not entirely sure I wanted these poisoned ants to die in close proximity to our cooking implements, I moved the cup a few inches away. The dragging ant stopped for a moment, apparently trying to determine what to do next, and eventually began once again to drag its compatriot toward the cup. Normally my first instinct when I see ants on the counter is to squish them or send in the blitzkrieg of Windex and paper towels, but I felt some remorse for my usual merciless assaults upon the citizens of the ant community. I let the ants be, and went about my business.