Home
top

What are web standards?

Validation

Validation is the process of controlling that a document obeys the rules of the language used in the document. You can compare it to checking a text for spelling and grammatical errors.

Validation is an important part of web development. Many errors that are hard to find are discovered during validation. An error can be as trivial as a typo, or as serious as an element or attribute being used in an invalid way.

Unfortunately, many people don’t validate their documents. Some people may not know about validation, others forget to validate, and there are those who intentionally avoid validating. This situation can largely be blamed on web browser vendors. Most web browsers attempt to interpret invalid HTML as best they can, and try to guess what the author’s intention is, instead of displaying an error message. This behaviour has led to the sloppy markup that is very common today. The problem with that kind of markup is that it gives unpredictable results and relies on the error handling of web browsers.

There is no reason not to validate your HTML and CSS. On the contrary. There are only benefits.

Why we won’t help you is Mark Pilgrim’s excellent explanation of the advantages of validation. The article also explains why it may be harder to get help from people on discussion forums and mailing lists if you haven’t validated your documents before asking for help.

Several HTML editors, like for instance BBEdit and Homesite, have built-in validation tools. If your development tool doesn’t have built-in validation, you can use the W3C’s validation services, available online:

Understanding the error messages generated by the validators can be a little tricky. An error early in a document may cause several additional errors. By fixing the first error an revalidating you will often greatly reduce the number of errors. Some common error messages are explained in Common XHTML Validation Errors at Black Widow Web Design.

It is always a good idea to make sure your code is fully valid, but there are a few occasions when some validation errors are difficult to avoid. The most common example is embedding Flash, or other content that requires a plugin, in a document. Read more about the problems with Flash in Flash Satay: Embedding Flash While Supporting Standards, and Embedding flash without <embed>.