Getting the markup on your WordPress pages to validate is not always an easy task. To make matters worse, those cryptic validation error messages do not always help.
I receive quite a few requests to assist with getting the markup on various blogs closer to validation. I enjoy doing this and I have thus far managed to help a few people. These efforts have however taught me a few things, the most note worthy of these is that everyone seems to be making the same mistakes. The following is a list of just some of the most common validation errors :
- unterminated comment: found end of entity inside comment. This normally means that you have forgotten to use the correct syntax for the comments in your markup. The correct format is
<!-- comment here -->
- literal is missing closing delimiter. You forgot to close one of your double quotes.
- end tag for X omitted, but OMITTAG NO was specified. You may have neglected to close an element, or perhaps you meant to “self-close” an element, that is, ending it with “/>” instead of “>”.
- end tag for X which is not finished. Most likely, you nested tags and closed them in the wrong order. For example
<p><em>...</p> is not acceptable, as <em> must be closed before <p>. Acceptable nesting is: <p><em>...</em></p>
- there is no attribute X. This error may also result if the element itself is not supported in the document type you are using, as an undefined element will have no supported attributes. Check the spelling and case of the element and attribute, (Remember XHTML is all lower-case)
- an attribute value literal can occur in an attribute specification list only after a VI delimiter. You have forgotten the “equal” sign marking the separation between the attribute and its declared value. Typical syntax is attribute=”value”.
- duplicate specification of attribute X. You have specified an attribute more than once. Example: Using the “height” attribute twice on the same “img” tag.
- required attribute X not specified. The attribute given above is required for an element that you’ve used, but you have omitted it e.g. the “alt” attribute is required for the “img” element.
- ID X already defined. An “id” is a unique identifier. Each time this attribute is used in a document it must have a different value. If you are using this attribute as a hook for style sheets it may be more appropriate to use classes (which group elements) than id (which are used to identify exactly one element).
- no document type declaration; will parse without validation. The document type could not be determined, because the document had no correct DOCTYPE declaration. The document does not look like HTML, therefore automatic fallback could not be performed, and the document was only checked against basic markup syntax.
- reference to external entity in attribute value. This is generally the sign of an ampersand that was not properly escaped for inclusion in an attribute, in a href for example
You will need to escape all instances of '&' into '&'.
These are of course just some of the errors that occur when validating WordPress pages but these are those that I have found to occur the most. Remember, markup validation is not just the responsibility of the developer of your theme, it is your responsibility every time you change the content on your blog.
I hope you have found some of this to be useful. Have you validated your pages?
Till next time.











Hi Lyndi. Useful tips (although I already know how to validate my code).
I have the HTML Validator addon installed in Firefox so I get a green tick if a site validates. It is rare to see a green tick. I wish more people cared about this kind of stuff.
Turnip needs to remove framespacing and allowtransparency from the CMF plugin code, although I may just remove them myself so my site validates, as those are the only errors on the front page. Well, according to HTML Validator, anyway.
Thanks Ben, it is worth noting that the different validators do tend to pick up different things. I definitely do not have the time to check things in all the validators.
Ben,
Thanks for the tip on the FireFox plugin. My blog validates, but found that my main directory doesn’t validate. What is weird, is they validate at the W3C’s website.
I get frame errors, so I have to look into what this is all about. Not sure if the errors are valid or not.
I figured out what what causing my errors, it was my Adsense ads. Now, I just have to figure out what code to change.
Nice compilation of validation errors.
I will refer this to validate my blog.
There is no definitive list of possible errors. In the end it all depends on your actual code. This list should help with those little things that so many seem to get wrong.
I always found w3c validator messages clear and easy… There are worse messages in the world (like C++ compilers). Ahem.
By the way had you tried CSE validator? I had posted about it few months ago http://www.rarst.net/software/html-validators/
C++ does go kind of crazy on the messages. When I started programming, the university I attended insisted that we all do a basic course in COBOL to start off with. This was equally crazy on the cryptic message side. When I saw this stuff I was very glad that I was not born a decade or so earlier, I would have hated to work with that stuff all day long.
I will check out the CSE validator, all I know about it is that it is an offline validator.
Lyndi.. These simple and easy tips helped reduce no. of errors on my blog. Thanks for this.
Glad it helped.
Wow, Great tips on Validation. Thanks!
Thanks
Another great tips from Lyndi and Ben on validation. I never check any validation errors in my blog before. Maybe, it will be easier with that plugin.
Woo hoo! I’ll have to bookmark this so I can use in the New Year
Thanks Lyndi!
Pleasure. Thanks for the visit.
I too have the HTML validator add-on for Firefox and I find it really handy. Even though I like nice clean code, I still think that quality content is far more important then whether your blog validates.
That’s just my 2 cents.
By the way, Lyndi, my visit is way over-due. You have a lot of good content here and I’ve bookmarked
I tend to agree with you but it depends on how far away the code is from validation. To me the moment bad code interferes with download times or proper operation, it should be fixed. Validation is actually just an early warning system. Thanks for the visit.
Lyndi,
thanks to you for mentioning the site’s validation, just now I used the service to test my site only to find out there was one extra/unneeded ‘</a…’ in the meta code. I must have forgot to delete it in there and who knows when?! I use the site validation to fix my html forms as they sometimes can be trickier.
BTW, to deliver presents on time to everyone on the Christmas day; How many homes/families does Santa Claus have to visit per one second, minute or hour in those 24 hours?
Quite a few validation errors are normally just something simple like this. Thanks for the visit.
Is there any information about this subject in other languages?
I am sure there has to be, you will have to Google for this I’m afraid.