New Proposal Could End the CSS Prefix Madness

CSS vendor prefixes are broken. What started out as a seemingly simple idea has ended up creating as many problems as it solved. Now a new proposal from a W3C member argues that the web needs a different approach.

Photo: Ariel Zambelich/Wired.com

The W3C continues to wrestle with the problems CSS vendor prefixes are causing the web. While they're useful for web developers, prefixed CSS rules as they are currently known may be causing more problems than they solve. Now W3C member Florian Rivoal has proposed a new solution to the prefixing problem.

CSS vendor prefixes were designed to help web developers by giving them a way to target CSS to specific browsers and use proposed standards before they were finalized. The idea was to move the web forward without rushing the CSS standards process. Unfortunately, it hasn't always worked out that way.

Rivoal blames the prefix policy itself, writing, "I believe the current prefixing policy is hurting more than it helps, and that the problems are fundamental to the policy itself, rather than something that can be blamed on various parties for not following it correctly."

The result is that the web is now in a situation where browsers are planning to start supporting other browser's prefixes, which just might defeat the entire point of having web standards.

Rivoal's proposal would change the way prefixes currently work and would solve some, though probably not all of the problems. Here's Rivoal's full proposal:

When a browser vendor implements a new CSS feature, it should support it, from day 1, both prefixed and unprefixed, the two being aliased. If a style sheet contains both prefixed and unprefixed, the last one wins, according to the cascade.

Authors should write their style sheets using the unprefixed property, and only add a prefixed version of the property (below the unprefixed one) if they discover a bug or inconsistency that they need to work around in a particular browser.

If a large amount of content accumulates using a particular vendor prefix to work around an issue with the early implementation in that browser, the vendor could decide to freeze the behavior of the prefixed property while continuing to improve the unprefixed one.

The biggest win for web developers – should Rivoal's proposal be implemented – is that it greatly simplifies the process of trying new features. It would give developers the tools they need to work around individual browser quirks with new features, but is less likely to lead to a situation like today, where WebKit-only CSS rules litter the web.

Another nice benefit of Rivoal's approach is that it solves the Opera dilemma – that no one is using prefixes for less well-known browsers. "No browser, however new or obscure, would have the problem of being excluded," writes Rivoal, "authors might not test in it, but if the browser does a good enough job of implementing the property, sites will render as intended."

Obviously this proposal is just that, but there's already an extensive dialog on The W3C's www-style mailing list and it appears that most members are supportive, though some have expressed reservations and possible problems. Mozilla's Henri Sivonen does a nice job of addressing many potential issues and shortcomings in a very long, thorough post to the mailing list.

It will likely be some time before any changes are made to the way vendor prefixes are handled, and of course none of this solves the problem that's already on the web today. But, hopefully, with a few changes to the way prefixes work, the web can avoid the WebKit-only problem in the future.