Q&A with GrandmasterB – Markup Validation
Posted on January 25th, 2009 by GrandmasterB under Q&A with GMB
It’s been quite awhile since I’ve posted anything new under the Question and Answers with GrandmasterB category, but today I received a great question in my inbox that I had to share with you all. The email was from my good pal Mike Cusden (you all know him as Cuzzy) from Cuzoogle. He had run his site through the Markup Validation script at http://validator.w3.org/ and it came back with quite a few errors and warnings, his question follows:
Hey GrandmasterB, I ran my site through the Markup Validator and it came back with a ton of errors. Are any of these errors fixable? And is it something that’s relatively easy to fix?
My first reaction was one of surprise, because every theme that I design and develop is run through to make sure that the code is 100% XHTML compliant before turning it over to the client. After taking a look at the output from the validator I could see exactly what the issue was and what needed to be fixed. For reference, I have pasted a copy of the report link here for you to follow along.
The problem that Cuzzy is having is that his theme code isn’t the problem, it’s the advertising code that he’s placed on the site. If you look at the errors that appear on the Markup Validation page, you’ll notice that the first error states the following:
Line 15, Column 107: cannot generate system identifier for general entity “MarketPlace”.
…om/widgets/q?ServiceVersion=20070822&MarketPlace=US&ID=V20070822/US/cuzoogle-
There are a couple of things to look at here to determine the error. First you’ll notice next to the warning icon the words “Line 15, Column 107″. This is where the line of code is found if you view the source code in a text editor like DreamWeaver or BBEdit. Since this error is found on Line 15, it is going to be found in the header.php file of the WordPress theme. You see the capital ‘M‘ is highlighted in red? That’s where the error is, if you read the description of the error it tells you that the ampersand before the letter ‘M‘ is uncoded. What that means is it doesn’t have the proper code tag. Instead of using just the symbol you would use this code: &
By fixing that one mistake with the ampersand, Cuzzy will be able to get rid of approximately 27 warnings/errors on his Markup Validation! Pretty cool and extremely easy to do.
How Do I Validate Markup?
I like to pull up my source code in Firefox and then copy and paste it into Coda (or your favorite text editor). I do that so I can see the line count and determine where the error is. I then open the file that contains that piece of code, in this case the header.php file. I don’t edit it though…what I do is “save as” and call it header.php.old and close it. I don’t like to edit working code, in case I have to revert back to the original. Open the header.php file again, make the change and then upload the file to your server. NOTE: If you’re using Coda, you can do all of this to your files that are on the server remotely and don’t have to worry about uploading files via FTP. After you make the change, go back to the HTML Markup Validator and click “revalidate”. The code will then be revalidated and you should see all of the errors for Line 15 disappear.
Markup Validation Tools
There are many tools available for validating your markup, but the good thing is that most of them are free! If you use Firefox, I highly recommend downloading Web Developer Add-on by Chris Pederick. Under the ‘Tools’ menu on Web Developer it has links that will run your site through the Markup Validator as well as a CSS Validator. For editing code, I use Coda (as mentioned before), but you can use whatever text editor you choose. I highly recommend an editor which has a line count display. If you do a Google Search for “Free HTML Editors” you’ll find all kinds of stuff.
Well, that’s it for this edition of Q&A with GrandmasterB. I hope that you all learned a little bit from this post. If anything it should shed a little light on markup validation and show you that it’s really something that you shouldn’t be afraid of. If you have any questions about markup validation or anything else related to web design or development, please shoot me an email. I would be happy to answer your questions…now, I’m off to make double sure my code is all up to par.
~ GrandmasterB



January 26th, 2009 at 8:49 am
Thanks a lot,
This is a great bit of advice…. I just realised that I have not run my own site through validation yet!!
Forests last blog post..Dress Your Affiliate Links – Free And Easy Cloaking Tutorial