Guaranteeing validity with the XHTML validator plugin
In this tutorial, we’ll explore why having a blog/Web site that validates is important, and how to quickly get your Turbocharged/WordPress site in shape.
What’s this validation stuff?
Valid, in the contexts of Web authoring and this article, means that your blog follows the XHTML standard.
That may sound hard, but it’s rather simple if we rephrase it into valid means your blog generates HTML code that makes sense to browsers and other machines.
Why valid markup is important
The thought du jour surrounding this topic is Hey, my browser shows the page alright, why should I care about validation?
That’s exactly the wrong approach. Let’s understand why, with a list of points:
- Most Web browsers, when they’re fed with invalid XHTML, revert to non-standards-compliant rendering. This can cause rendering of your (hopefully beautiful) pages to mess up.
- WordPress is not just an XHTML rendering machine. It also renders to a variety of syndication formats, including RSS and Atom, both being XML formats. Feed readers are not as tolerant as Web browsers, and they’ll generally barf their guts out on invalid XML.
- Some enhancements available for WordPress (and Turbocharged) actually require valid XML in order to do their work.
- Search engines and your advertising networks need to “guess” what you meant instead of actually obeying your intentions. This can hurt you where it hurts most: in your pocket.
Let’s sum up. Your pages may not render well; your syndication audience won’t be able to read you; your blog may malfunction. Still think validation is a minor issue?
The validity game: it’s easy
Fortunately, writing valid XHTML with Turbocharged (and WordPress) is quite easy. You have two options:
- write with the included rich text post editor — barring a few issues with spurious line breaks, it’s quite good and it produces valid markup
- write using the simple post editor and Markdown — we’ve covered that issue in another tutorial
That should help you a 99% in the validity game.
Note I said should. This means the onus to check for validity is still on your side. Here’s where this tutorial helps.
Diagnosing validity
To check for validity, you’ve got a ton of online resources. My favorite is, of course, the classic WWW Consortium (W3C) validator. You feed it the URL of your article, and it’ll tell you if it’s valid.
If it’s invalid, you’ve got two issues to look into:
- Your template may be generating invalid XHTML. How can you tell if this is the case? Well, if two or three articles show the same list of errors, that’s your cue. Solution: switch to a different template or have a professional service
- Your article or page may contain invalid XHTML. You’ll be able to diagnose this if it’s just that one article that’s showing errors.
Fixing an invalid template is easy. You fix one incorrect tag, and you fix tons of errors. So, in this article, I’ll show you how to easily fix the second class of issues.
Is your content valid? Let the XHTML validator plugin answer that!
It would be unreasonable to check each and every page of your blog or site with the W3C validator, wouldn’t it. So, at first, it seems like a monumental job.
And it would be monumental, were it not for the XHTML validator plugin, bundled with Turbocharged, and free for use in WordPress blogs. It sports two distinct helpers:
- real-time checks of your posts: each time you hit Save and continue editing, it alerts you above the post editor area if the markup of the article is invalid
- mass validation: you can see all articles and pages with invalid markup in a single screen, with convenient Edit links and, sometimes, suggestions for a quick fix
Installing the XHTML validator plugin
Installation of the XHTML validator plugin is not involved at all. It installs just like any WordPress plugin. If you’ve never done that, we suggest you get Turbocharged, which bundles the plugin and support to answer exactly this type of question.
After installing the plugin, you need to install one or both of these tools on your Web host:
- tidy, a known, reliable tool that checks for HTML validation
- xmllint, another well-known tool that checks for XML well-formedness
Since the installation process of those tools falls outside the scope of managing your Turbocharged site, I’ll just suggest you use your Web hosting’s software installation facilities, and refer you to your hosting’s support staff for that.
Finally, activate the plugin in the Plugins screen of your Turbocharged or WordPress management console.
Validating as you write
Well, there’s not much you need to do. If you want to ensure the markup in your article is valid before publishing it, hit Save and continue editing before hitting Publish. You’ll see a warning if it’s invalid — and if you do, it’s time to pop into the source view and see what’s wrong.
(I should just go ahead and leak that a new feature is planned in the XHTML validator plugin: it’ll tell you directly what the source of the problem is.)
Some plugins sometimes produce invalid XHTML from originally valid XHTML. If the warning lets you know that, you should turn plugins off one by one in an attempt to diagnose the issue. That can get tricky — I certainly hope you don’t encounter that issue.
Validating all your articles at once
How you do this in Turbocharged
Step 1: click Manage. Step 2: click XHTML validator. Step 3: hit the button!
Step 4: use the results screen to fix your posts.
Useful: the Messages window
The XHTML validator plugin has another feature: mass validation.
Suppose, for a second, that you’ve been nurturing a blog for ages, and you’ve written hundreds of articles. It’s reasonable to presume some of them may have errors, but you simply can’t afford to run the URL of each article into the W3C validator.
Enter the mass validator, available through the WordPress management console, under Manage -> XHTML validator.
Just follow the instructions onscreen. Which basically amount to:
- hitting the Validate my content now button
- using the next screen to fix your articles
The next screen will present a series of rows — one for each invalid post, page or comment. Use the Messages button to pop up a window with the messages from the validator, including where the error was found.
If you have tidy, and tidy has figured out a quick fix, you may elect to apply it — check the Messages window to find out what the quick fix is. Otherwise, you may click the Edit link — I suggest you manually open it a new window — and fix the entry using the messages to correct the mistake.
Valid = good
Validation used to be a real pain. Today, thanks to the XHTML validator plugin, and bundled tools such as Turbocharged, it’s no longer a problem. There’s no excuse to spew out invalid markup anymore.
For those of you who still aren’t Turbocharged customers: may I suggest you get Turbocharged today?
April 15th, 2007 at 11:54 pm
[...] WordPress user? Then check this tutorial out! [...]