I believe (X)HTML should be well-formed. I believe all sites should have valid markup and style sheets. I believe all sites should undergo validation processes. I do not believe that valid code needs to pass validation. There is a difference between writing valid code and writing code which validates.
I had been musing on the difference between “valid code” versus “validated code” for a while when Robert Nyman wrote Worst code you’ve ever seen? [January 16, 2007] wherein he dared others to divulge their worst found code. That was followed by Worst code ever as published by Roger Johansson [February 14, 2007] and it has this line,
“I think valid [Elementary emphasis] code that blatantly disregards best practices is at least as insulting as invalid tag soup...”
I agree with the sentiment of Roger’s statement but not the statement itself. What about valid code knowingly written by web standards advocates that selectively disregards best practices?
(X)HTML markup validation means that a document’s markup language has been validated against a particular specification’s requirements. Validation does not mean the markup language is valid when one includes “best practices” guidelines.
- Valid HTML 4.01 markup will fail validation if it is submitted with an XHTML 1.0 Document Type Declaration. Conversely, valid XHTML 1.0 fails with an HTML DocType. The code remains valid even when the DocType has not been declared.
- An otherwise structure/presentation separated page with a single presentational table which contains one row which contains three cells used as same height divisions passes validation but it fails web standards’ “best practices” while meeting a site's need.
CSS validation means that a document’s style sheet has been validated against a particular specification’s requirements. However, some valid styles fail.
- Proprietary styles are valid. They are valid because they function in the specific User Agent for which they were written. They fail validation because the W3C does not accept the prefixed extension(s).
- The “Underscore Hack” is valid but, because of the “Keywords and property names beginning with ‘-’ or ‘_’ are reserved for vendor-specific extensions.” statement in CSS 2.1, paragraph 126.96.36.199, it fails validation.
Fortunately, comments made in the article Validation is more than pretty fonts and unencoded ampersands by Christian Montoya [February 28, 2007] somewhat addressed my thoughts. Particularly, Mike Davidson’s. Though, they didn’t resolve them.
Some code that validates is not valid; some code that is valid does not validate.
So,— What makes valid code valid?