Smuggling Proprietary CSS and the Validity of the Validator

Will makes an interesting point in his blog post about using browser-specific CSS and still having webpages validate. His quandry:

Have you ever been tempted to use a CSS property such as -moz-border-radius, but can’t stand the thought of having a page that refuses to validate?

He can’t add it to an external stylesheet through <link>, nor can he use it internally within <style>; if he does, neither will validate.

However, adding the proprietary CSS to a style attribute on an element gets around the problem, since the W3C HTML validator does not check the validity of CSS within style attributes.

Observe; the code below uses the -moz-border-radius, but the resulting HTML will still validate.

The code:

<div style="padding: 0.25em 0.5em;
   border: 2px solid #605953;
   -moz-border-radius: 25px;
   background: #f1efec;">
Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
</div>

The result:

Lorem ipsum dolor sit amet, consectetuer adipiscing elit.

On the one hand, it’s a neat trick (not necessarily a hack) that gets around the validator and allows a developer to use non-standard styles on his page. On the other hand, that’s exactly it: it’s non-standard; and I agree whole-heartedly with Will, who so colorfully elucidates:

Yeah, it is kind of an ugly method, but you shouldn’t care since if you’re going to use it, right? After all, depending on proprietary CSS is like depending on a rotten wood catwalk over a tank full of the proverbial kind of bovine fecal matter.

All of the above got my brain thinking about validation and standards.

The W3C Validators are not the end-all-be-all definitive sources for creating standards-based websites. As Will (and now I) have successfully pointed out, proprietary (and, in most cases, non-standard, non-valid) code can be “smuggled” into a website and can trick the validators into thinking the code is perfectly valid.

The point is that standards are about much more than just validation. They are also about what works for you. You may have a certain work ethic, i.e. a personal standard, that no one else has heard of, let alone uses for himself. Does that make your work ethic any less valid? Pft. Of course not.

Any Joe with an Internet connection and a text editor can create a page that validates and claim it’s “standards-compliant”. As Mike Davidson wrote almost twenty months ago:

Web standards are about all the processes involved in publishing information over IP. [...] Just because you can validate your code doesn’t mean you are better than anybody else. Heck, it doesn’t even necessarily mean you write better code than anybody else. [...] Spewing validation manifestos on message boards isn’t going to show you how to listen, negotiate, compromise, and execute.

One Response to “Smuggling Proprietary CSS and the Validity of the Validator”

  1. Will says:

    Thanks for the link, Andrea!