The HTML Validator is a program that checks the syntax conformity of an HTML document. Ideally an HTML validator recognizes errors in the document and displays the error source.
An HTML validator is specifically used to verify compliance with the DTD (Document Type Definition), in other words to perform a validation check of a document. It examines a document for missing or incorrect elements, attributes, and other errors.
Another example of the general use of a validator is checking for correct spelling in a document.
A continuation of the HTML validator is the W3C Validator, which in addition to pure HTML code also checks the following documents:
Specifically, it checks for the respective pages whether the conventional syntax has been applied correctly. This includes setting commands, parentheses, etc., as well as proper nesting. For this purpose, the validator checks the specification used and marks any elements as errors that were either formulated or used incorrectly or that are not present in the specification.
Just because an HTML validator finds errors in syntax, does not automatically mean that you have unclean code. Often the owners of websites specifically add commands in their HTML files, which allow older browsers to display the page properly. A new browser may not be able to do anything with these commands, the HTML Validator will therefore display them as errors. In fact, however, they are purposely integrated to increase the compatibility of the website.
A review of the results of the validator makes sense in any case. Sites with hundreds or even thousands of code errors often result in a faulty display. This is reason enough for the operator to address it in detail. However, tinkering with all one’s might on the code until the HTML validator reads zero errors is not necessarily always the right way either, since meaningful code structures may be lost.
As a general rule, a clean HTML code is also considered a ranking criterion, specifically because Google writes the following in the Google Webmaster Guidelines: “Check your webpages for faulty links and ensure correct application of HTML syntax.”
In a Video for Google Webmasters however, Matt Cutts stated that Google does not use valid HTML code as a ranking criterion because there are too many websites with bad code. If you would have these websites rank lower, many sites with valuable content would disappear from the scene. However, Cutts nevertheless recommends to pay attention to a clean code to ensure the maintainability and upgradeability of the site. He also does not rule out that Google’s point of view in terms of a valid code could change at some point, then it would be better if you were already well-prepared in terms of search engine optimization.