WordPress linking causes validation problem

Inserting a link in WordPress 2.5.1 can cause a validation problem. The problem arises when you insert a link using the Visual editor mode and include a title attribute, generally regarded as highly desirable for reasons of accessibility and promoting your content. The HTML for such a link looks like this:

<a title="Paul Left's blog" href="http://www.verso.co.nz">

W3’s HTML validator doesn’t like this tag: it seem that having the title attribute before the href attribute is invalid code according to the WordPress document type. So the link code should be:

<a href="http://www.verso.co.nz" title="Paul Left's blog">

I click on the HTML tab and go through the code prior to publishing and edit any link tag to ensure the title attribute follows the href attribute. It’s a minor nuisance but there doesn’t appear to be any way to configure WordPress to avoid this. I’m using Firefox and Mac OSX but the same problem happens using Window XP so I assume it’s platform-independent.

The significance of the validation issue is open to heated debate but it does seem desirable to post pages with valid code where possible.

2 thoughts on “WordPress linking causes validation problem

  1. Paul Left Post author

    I’ve since found that if I swap to the visual editor prior to saving the post it puts the title tags back in the wrong place for all the links in your post!

    So the only solution if you’re using the visual editor is to wait until you’ve completely finished editing the post, then swap to html mode, fix the tags as described, then save the post. Finally, cross your fingers and hope you never decide you need to edit it again…

  2. Pingback: Validation problem with Feedburner email subscription | Verso

Leave a Reply

Your email address will not be published. Required fields are marked *