[Skip to the Main Content]

What makes Valid Code Valid?

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.

Two Examples:

  1. 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.
  2. 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.

Two Examples:

  1. 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).
  2. 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, 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?

Sean Fraser posted this on March 2, 2007 05:01 PM.

  • Add to Technorati Favorites
  • de.licio.us: http://www.elementary-group-standards.com/web-standards/what-makes-valid-code-valid.html
  • furl: http://www.elementary-group-standards.com/web-standards/what-makes-valid-code-valid.html
  • reddit: http://www.elementary-group-standards.com/web-standards/what-makes-valid-code-valid.html


Comment Here

Reply guidelines: Basic HTML (a href, p, code, blockquote, dl, dt, dd, ul, ol, li, cite and q) are allowed. Line breaks and paragraphs are automated.

Inappropriate, unwarranted or self-aggrandizemented comments may suffer redaction. Or, deletion.

[Note: A gravatar, or globally recognized avatar, is that small image in the comments. Gravatar sets-up them.]

The Elementary Standards: A Compendium of Web Standards, CSS, Linguistics and Search Engine Optimization methodology Copyright ©2005-2007 Sean Fraser. All work is published under a Creative Commons License. All Rights Reserved.

Palm trees on a grassy field in Hawai’i

Main Content Returns thus