Top 5 Ways To Keep Your WordPress Blog Valid (And Why It Matters)

Posted on Wednesday, May 9th, 2007

Making your blog look good and work well is a major consideration of anyone who wants to do well in the blogosphere. Making sure your blog is valid and adheres to the standards of the W3C will ensure that your theme will look good in all browsers, even those yet to be released, be more accessible, easier to maintain and easier for search engines to crawl. So how do you go about making sure your site sticks within the guidelines?

A Great Base

One of the best things about WordPress is it’s commitment to web standards.

Key Features

Full standards compliance — We have gone to great lengths to make sure every bit of WordPress generated code is in full compliance with the standards of the W3C. This is important not only for interoperability with today’s browser but also for forward compatibility with the tools of the next generation. Your web site is a beautiful thing, and you should demand nothing less.

WordPress About page

So WordPress endevours to display valid code at every step. Then there are themes. Any theme designer that’s worth anything will make sure their themes are valid (X)HTML and cross browser compatible to fit in with the ideology above.

So how do you stop your theme from falling apart, causing hundreds of errors in a validator and becoming harder and harder to look after? I have noticed a few common mistakes in the (X)HTML of many blogs that I have visited, so here are a few tips on how to stay valid.

5 Tips And What Might Happen If You Don’t Follow Them

Add alt attributes to all your images.
Whether it’s an image in a post or a button on your sidebar, you need to include the alternative text. Without it, your blog is invalid and users who can’t view images won’t know what was supposed to be seen. The alt attribute is also useful as a bit of extra search engine optimisation, if your alt attribute describes the image and the image is relevant to your post, then there are more keywords available for the search engine bots to feed on.
Adding the alt attribute:
<img src="image.gif"
alt=”Short description of image” />
Close all your elements.
In HTML it was OK to write paragraphs as follows:
<p>Some text here in the first paragraph...
<p>Second paragraph here...
But in (X)HTML this no longer works, you need the all important </p> at the end of every paragraph (or the </li> after list items, or </ul> after lists, the list goes on). Not only will sticking to this make your code clearer to read, but not closing elements properly can mess up any javascript on the page too! So those paragraphs above should look like this:
<p>Some text here in the first paragraph...</p>
<p>Second paragraph here…</p>
Self close those single elements.
It’s all very well closing paragraph and list elements, but you can’t forget line breaks (<br />), images (<img src="image.gif" alt="example" />), links (<link rel="stylesheet" type="text/css" href="style.css" />).
They all have one thing in common, the trailing />. Make sure you include it too.
Make your lists behave.
WordPress uses lists a lot! Most sidebars are unordered list after unordered list, for the semantic and accessibility factors they provide. All too often this can be spoiled by an out of place paragraph or div or even another list. For example:
<ul>
<p>Out of place paragraph.</p>
<li>The real list</li>
</ul>
Just rememeber, whenever you are between an <ul> and an </ul> you must also be between a <li> and a </li>.
Embed videos properly.
I’m not one for video blogging, or even dropping in the occasional YouTube video, but many bloggers do and embedding flash content is hardly ever done correctly. For a start the <embed> element has never been supported by the W3C, it was made up by Netscape in the days of proprietary browser HTML. The way to do it is using the <object> element. I’m no pro, but there are two articles on embedding flash at A List Apart that clear things up.

So there you have it, 5 things you can watch out for to keep your blog posts and your theme valid. While they seem harmless now, when browsers move on the standards will stay the same and the valid and well constructed sites will last.

If there is anyway I can help and point out where your theme could be fixed up, please let me know and if there are any other tips you can give for keeping a site valid, please do share.

Update: Please check out my next post for an easy and quick way to check whether your pages are valid.

This post is part of the ProBlogger group writing project. If you have written a top five post, I look forward to reading yours too.

If you enjoyed this post, why not subscribe to Unintentionally Blank

Comments

  1. Pingback by Top 5 - Group Writing Project Day 3

  2. Pingback by Group Writing Project - Day 3

  3. Pingback by Some good posts I managed to read today

  4. Pingback by Top Five Group Writing Project: Day 3

  5. Duncan Says:

    Thanks for this Phil. As I started using the XHTML tests provided by Wordpress I discovered a few of these things. I haven’t worked out how to keep the Blogshares widget in XHTML compliant code. Any thoughts?


  6. Pingback by ear sucker » Blog Archive » Group Writing Project Day Three

  7. Randa Clay Says:

    Thanks for this Phil. I’ve never really taken the time to completely understand this, so I appreciate this post.


  8. Pingback by Group Writing Project - Top 5 Day 3 | Techie Buzz

  9. Pingback by Group Writing Project - Top 5 Day 3 : WinonBet.org

  10. Phil Says:

    Duncan: I’m afraid I don’t know the Blogshares widget. If you could show me an example I’ll have a go though!

    Randa: No worries! There are obviously lots more points to it, but these are the most common that I’ve seen. If you want any further tips, drop me a line!


  11. Pingback by Everyday Randomness » Group Writing Project Update

  12. Pingback by Travis Eneix » Some Pyramid Schemes are Nice

  13. Pingback by Everyday Randomness » Top 10 Group Writing Project Entries

  14. blogjunkie Says:

    Hi, I’m the blogjunkie from myMacBUZZ. I’ve been looking for an automatic validation monitoring system instead of having to check the W3 Validator every day. Do you have any suggestions?

    Check out my entry for Darren’s group writing project too.


  15. Pingback by The Easiest Way To Check Your Site’s Validity :: Unintentionally Blank

  16. Phil Says:

    Hi blogjunkie, thanks for commenting.

    Your comment actually reminded me of something I was going to put at the end of this post, but left out in the end. Here is how to validate your blog easily.


  17. Pingback by   The resourceful webdesigner’s toolkit. — BlogoSquare

  18. Pingback by Top 5 Group Writing Project

  19. Pingback by Perfection Consulting » Blog Archive » The Power of Linking

  20. Pingback by Top 5 Group Writing Project: And the Lucky Winner Is? | aczafra.com [Librarianship with a dash of everything]

  21. Pingback by Jestertunes » Group Writing Project Full List

  22. Pingback by Two Dog Zoo Travel » Blog Archive » Group Project Brought in 800+ Entries!

  23. Pingback by Randomness: 893 Top 5 Lists… | Photography and Art, Mostly…

  24. Pingback by Top 5 Group Writing Project Is Now Complete

  25. Pingback by Some link love to fellow Group Writers | Blogging Notes

  26. Pingback by Madhur Kapoor’s Blog » Problogger’s Group Writing Project - All entries

  27. Nyssa Says:

    Some excellent tips there, even for me. I think even those that generally know what they’re doing tend to forget to close tags and such. It’s not hard to do.

    Great article, Phil. :)


  28. Pingback by ProBlogger - Top 5 - Group Writing Project - Link Love » twentythree7

  29. Pingback by Problogger.net Top 5 Writing Project Final List - Plus6 …a personal finance blog

  30. Pingback by Juice on Celebrities, Celebrity Gossip, TV, Movies, & more… » Blog Archive » Top 5 Lists

  31. Pingback by Quais Waseeq Dot Com » Top 5 Group Writing Project - Recap

  32. Pingback by A million top 5’s

  33. Pingback by Randomness: 893 Top 5 Lists... | Photography and Art, Mostly…

  34. Pingback by   Things you should know when using the div element — BlogoSquare

  35. Pingback by Joseph Szymanski | Photographs | » Blog Archive » Randomness: 893 Top 5 Lists…

  36. Pingback by Useful WordPress links.

  37. Pingback by Group Writing Project - Lista Final - Rockerspace.net

  38. Pingback by A surefire way to get links and traffic for your blog » All Tips and Tricks

Leave a Comment