Validating XHTML

On 15-Feb-2006, in tips and tutorials, by Martin

Housekeeping my xhtml Call me a purist. I just like to have my code valid. It is also far better for your feeds aswell. They rely on valid code. Lorelle has dug herself into this aswell a while ago and she came up with some tips and hints which might interest you too. Offcourse you [...]

Housekeeping my xhtml

Call me a purist. I just like to have my code valid. It is also far better for your feeds aswell. They rely on valid code. Lorelle has dug herself into this aswell a while ago and she came up with some tips and hints which might interest you too. Offcourse you should look at WordPress too for they wrote some good stuff on the subject too.

HandsOn experiences with validation

I decided today to do some housekeeping on my postings and pages in general. Guess what… Errors at the validating service from W3C. One very specific error I wasn’t aware of is that you just can’t put <p> everywere. They need to be at the beginning of the lines but not, this was my mistake, nested around an <ul> or an <ol> listing. This just is not up to standards. Just look at a quotation from Elliot Back’s site:

Incorrect nesting of lists. Please do not place lists inside a paragraph tag. The w3c reports this error as “document type does not allow element “ul” here; missing one of “object”, “applet”, “map”, “iframe”, “button”, “ins”, “del” start-tag.

I found this piece of extra learning at this site here from Elliot Back. He describes, in good to understand language, what the basics are for valid XHTML. I can sincerely recommend it to you.

WordPress Plugin

I thought it might be a good idea to have look around for a suitable plugin that would ease the pain of those errors a bit. It just happens to be that both the standard WordPress editor and the advanced TinyMCE editor aren’t that great at valid coding. What’s more both WP and the editors are sometimes a teeny bit illusive. I just can not always fathom why a piece of [x]html is coded that way or another. I am used to that hands-on feeling with it. So to take matters in my own hand I activated this plugin from Jamie Talbot. It is called ‘XValid’ and as far as I can tell does the job very good. It even tells you what, if any, errors have been corrected. You have full control over what happens to your coding. What is important is that you deactivate WordPress’s own XHTML correction. You can find it under Administration-panel->Options->Writing. Just uncheck the validator from WP where it says “WordPress should correct invalidly nested XHTML automatically”. What is also important for your site’s validations to Xhtml (be it transitional or strict) is the way XValid can email you as the administrator on comments being added that aren’t valid. Or have errors in them. This way you can correct those errors and still have a very clean site.

Validation Resources

These resources will help you validate your web pages and code and can help you understand a little more about how validation works.

HTML – Validation

 

6 Responses to “Validating XHTML”

  1. Lorelle says:

    You probably already know this, but for your readers, most advertising or javascript code that includes an ampersand will not validate. I found out that you need to change the & to &amp; and it will still work and the code will now validate. I hated that so I was relieved to finally find a fix that makes the code work and validates at the same time.

  2. Martin says:

    Yes I do actually. The validating thing that still makes me a bit crazy is caused by the use of ‘excerpts’. It is a built in feature by Binarymoon on the ‘Regulus’ theme we both use. When I started out it seemed a good thing todo, to use the excerpts. On hindside I am not really sure. It’s a bit wacky from time to time. There is only one thing to it. Per post, per comment, validation comes twice here. Ah well, I can live with that. Thanks for the comment. Always appreciated. BTW did you manage to adjust the ‘dutch’ to ‘german’ translations yet? Mailed to you on cameraontheroad.

  3. Martin says:

    Another thing we have to mention to the audience is the fact that only a single & is a faulty one for validation. I just tested this on a remote script I use for stylesheet switching from Paul Sowden at Alistapart. In that script you’ll find double & symbols like so &&. When I changed them to && the script failed. So validation only requires that single & signs need to be converted to their UTF-8 counterparts, &. And then something else. Since we are indirectly speaking about encoding, an ampersand (and many other symbols) can also be coded like & without a problem. Strange because WP is built around UTF-8 (look in your header for the meta). How come I wonder?

  4. Martin says:

    Sorry but here is WP playing me parts again. My comment before this is confusing. I tried to write ampersand signs in to 2 different encodings but WP simply converts them back to plain & signs. When you look at the source you will know what I meant. :{

  5. Lorelle says:

    I got the ampersand thing. PITA! And no, I didn’t get your email. Sorry.

  6. Martin says:

    That is a pity. What is ‘PITA’? The email was about the tab “WordPress resources” on ‘Lorelle’s’. Your are offering some links that translate the WP manual. Amongst them you mention a ‘dutch’ version. Helas that’s a German version. I asked if you could correct that and if you know one in Dutch somewhere?

Leave a Reply

Free WordPress Themes

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Free WordPress Themes