Ideally all your pages would be 100% valid, though it’s not practical or even desirable at times to achieve 100% validation.

Some code that’s commonly used just won’t validate.

Your doctype is setting the language you’re using and code that’s valid under one doctype may not be valid using another.

xmlinputfactory is validating-76

Xmlinputfactory is validating video

Validating your code is simply comparing it to W3C standards.

Much as different languages have different rules of grammar, the code you use can have different rules depending on the doctype you use.

Different browsers may treat invalid code differently and sometimes in unexpected ways.

Some will probably tell you that valid code will help your pages rank better. Other than show stopping errors (which validation can help you find) search engines really don’t care much about your code.

Vender specific prefixes such as -webkit and -moz will never validate by definition.

That doesn’t mean you shouldn’t use those vendor specific prefixes.

For example forgetting to close a tag early in your document could end up resulting in dozens, even hundreds of errors.

Fix those one or two errors and watch as many more errors are gone when you revalidate the page.

The reality is as long as your site and pages display like they’re supposed to your visitors aren’t going to care whether or not the code behind your site is 100% valid.

Browsers won’t care much either as they’ll typically render much invalid code perfectly fine. Still there are good reasons to validate your code.

I’ve included some screenshots at the bottom of this post to show the full code I used to check under each doctype.