The Importance of XHTML Validation

When will I ever learn?

Miraz has told me again and again — validate your pages after making changes to your WordPress theme templates. She even advised readers in our book, WordPress 2: Visual QuickStart Guide. And every time I validate, I find errors, proving that it’s a step I really do need to take.

Yet I continue to skip this step when I tweak my theme’s template files on every single blog I run.

This morning, I got an e-mail message from someone named Tine who wrote:

I’m completely new to WordPress but found your site because of the book you have made and was curious.

Are you aware that your blog don’t look good in Explorer 6? Some of the text to the left is cut off.

I use Explorer 6 on XP Pro and 1024×768.

Uh-oh.

I fired up my PC and loaded up my home page in Explorer 6. The situation was worse than Tine reported. What appeared did not look much like my site at all. And in the status bar, Explorer was politely telling me that page had errors but didn’t offer any way to find out what they were.

My first instinct was to panic. But then I remembered the XHTML validator at http://validator.w3.org/. I ran the page’s URL through the validator and settled down to find and fix the 110 errors it found.

Sheesh.

The main culprit in this case was some code I’d inserted into my post.php file to display RSS links beside category names in each post’s header. This rather slick piece of coding, which I was pretty proud of, contained the dreaded unencoded ampersand error. That means I’d included & in the code when I should have included & in the code. That error was all over the place, but Explorer seemed to be choking on it in the new code. When I fixed its first occurrence and reloaded the page in Explorer, the page appeared fine, although the status bar smugly reported that there were still errors in the document.

Other problems included

    and tags without

  • and tags. Oops. And

    tags without tags. (It appears that ecto was causing that problem in the way it codes Technorati tags. Good thing I’m not using tags in my posts anymore.) Of course, all my Amazon.com book cover links were missing alt attributes. And some of my rotating ads used IMG instead of img for coding. The list goes on and on.

    Of course, if I’d been validating the XHTML after each template change as Miraz recommends, I would have caught these errors as I introduced them. I wouldn’t have spent my Sunday morning debugging code.

    Have I learned my lesson? I think so. At least for a few days.

    One thought on “The Importance of XHTML Validation

    1. While I believe it is important to validate code, I feel it is equally important to update my browser versions. The responsibility of usability and accessibility falls at least in part to the user. If I am using obsolete software and hardware, how can I possibly complain to a developer about issues I am having. Technology changes so fast. I am responsible for keeping up with those changes; lest I be left behind wondering why I can’t enjoy and experience the latest and greatest. IMHO – IE6 and other IE versions are fraught with negative issues. Why would one want to continue to use these antiquated browsing options?

    What do you think?