Stop Forking with CSS3

by Aaron Gustafson

61 Reader Comments

Back to the Article
  1. Good concept but the eCSStender example page (Spoooon) looks very different in different browsers. It looks great in Safari and very good in Chrome (no drop shadows). There are drop shadows in Opera, but the action of the color boxes is not smooth. With Firefox, there are white letters against a blue square and no moving color boxes. IE 6 cuts off some letters, which are located in the upper left corner, with no color or moving boxes on hover.

    Copy & paste the code below to embed this comment.
  2. I’m sorry, I appreciate the want by some to indulge in extending CSS, but aren’t what is referred to as hacks actually standards compliant vendor prefixes that will eventually dissappear once fully integrated to the specific browser that simply allow for the vendors (and experimental coders) to start testing these new additions to the CSS fold?
    I just feel the hack comparison slightly misplaced, although I concede for the time being the code looks bloated, it is neither ‘forking’ or ‘hacking’.

    Copy & paste the code below to embed this comment.
  3. HI Aaron

    I’m not sure it’s a good idea to hide away vendor prefixes. They are there precisely because some people want to use experimental CSS, like border-radius for example. WebKit and Firefox used different syntaxes precisely because the spec was still in flux, and they correctly used vendor prefixes as this was an experimental implementation. (Opera, by the way, has supported border-radius reliably since version 10, without any vendor prefix and using the final syntax.)

    Other uses of vendor prefixes are for proprietary vendor extensions to CSS, such as gradients. Again, WebKit and Firefox have non-interoperable syntaxes so vendor prefixes are the only way to make sure that each gets the right rule.

    Developers should use each vendor prefix in their code; I advise writing the declarations in alphabetical order (so moz, ms, o, then webkit) and finally having a declaration with no vendor prefix, for future browsers that support the final standard. Sure, there’s a risk that the standard might change but if you don’t use the non-prefixed version, you are guaranteed to lock out other browsers – in the same way that if your code doesn’t use plain border-radius, you guarantee that it will not work in IE9.

    This is a developer’s responsibility. If you as a developer choose to use experimental, pre-standardised code on a production site, then you need to live with the consequennce of that choice.

    Copy & paste the code below to embed this comment.
  4. I have read all 5 pages of comments and I think a little controversy is good. Let’s everyone know there is a viable issue at hand. Many good points. This banter reminds me of something else… the screen resolution debacle.

    I was going to JS-Fork a website for North American audiences vs. “Global” audiences because I mistakenly believed that there needed to be smaller screen res for the Global community. Turns out that on average, it is the Americans using the highest % of 800×600. In that discussion, several “experts” stood firmly by the 760 for websites – in 2010! Others argued the fluid layout rule. Seems many people can’t maintain “enough” flexibility, combined with “enough” ingenuity, combined with enough “common sense” to render a real decision about the value of a given technology.

    I love the “functional” arguments whose thrust seems to be educating others how this library will function case-specific for them. Function is an Applied Science, not a Pure one.

    I think the library is a great idea which hits its mark and performs a valid service to the much sought after styling of the day. By the time there are standards for border-radius, the hype over rounded corners will be over, (I am using square and round alternating corners for a balanced, masculine/feminine appeal) and it will be left to a designer to express (semantically) what should be either function or fancy.

    In the meantime, tools help take the bleed out of the cutting edge. Thanks, Aaron.

    Copy & paste the code below to embed this comment.
  5. Any time you can move complex work to the server side, you’re going to get a speed improvement and we may add in some server-side components down the line (we’re certainly not ruling it out), but when most people ask this question, they’re weighing eCSStender against a CSS pre-processor like Sass or Less.

    Putting aside the debate over whether alternate CSS syntaxes are better or easier to use, there are definite advantages to using a tool that can translate one syntax into another (as some extensions do), but when your solution is 100% back-end, it does not allow for nuance and interpretation, which is where eCSStender excels.

    At the core of eCSStender’s power is the eCSStender.isSupported() method. This method allows a developer to test for property and/or selector support and then act upon their findings. Using this method, an extension can see that Safari 4 (and other Webkit-based browsers of its generation) doesn’t understand border radius shorthand with unequal radii (e.g. border-radius: 2px 4px;). If your preprocessor only knows to translate border-radius to -webkit-border-radius, -moz-border-radius, etc. and isn’t aware that it also needs to check the values and make further augmentations for Webkit, that’s a problem. And, if your preprocessor is pushing all of that extra markup over the wire, regardless of whether it’s useful to the browser, that too can become a problem.

    Additionally, a pre-processor can’t leverage that nuance to implement JavaScript-based animations as an alternative to CSS-based ones if they aren’t supported because the pre-processors (as they are currently built) take a “one size fits all” approach to handling CSS: everyone gets the same thing. Then there’s also the fact that eCSStender can help you implement a new property or concept you’ve conceived and make it work in the browser in a much more robust way.

    There are definite advantages to using a CSS pre-processor, but nuance and conditional translation/augmentation is what makes eCSStender different.

    Copy & paste the code below to embed this comment.
  6. I forgot Tick used to yell, “Spoooon!”.

    Thank you _

    Copy & paste the code below to embed this comment.
  7. After reading the article, I was expecting some display consistency between browsers for the demo you provided. Is it not supposed to display correctly in IE? Maybe I completely missed the point?

    Demo provided
    http://ecsstender.org/demos/spoon/

    Copy & paste the code below to embed this comment.
  8. Unfortunately, IE’s support for advanced things like rotation, gradients, etc. relies largely on the non-standard filter property in CSS and, like CSS shorthand, any time you set filter to a new value (which each extension currently tries to do) it supplants anything that was there before instead of adding it to a stack (which is what we really need to happen). We’re currently looking into this limitation and are working with the IE team to figure out the best overall approach to allow access to and manipulation of the filter stack (so we can enable animation of these properties, for instance).

    It’s a bit much to wrap my head around at the moment, but I assure you it’s in the works. That said, most of the extensions out there work fine in IE. The only place you run into issues is where you have a combination of properties that need to write to filter being applied to the same element. That’s what’s happening in the case of the Spoon example.

    Copy & paste the code below to embed this comment.
  9. So to clean up the messy CSS with -webkit, -moz vendor specific properties, we add a Javascript? What good is that going to do?

    Copy & paste the code below to embed this comment.
  10. Even though the idea sounds great, I think there is still a way to go. Because eCSStender is 18kbs now but all the weird css in the article has been exampled only takes 726bytes. If we multiply that with 10 bordered stuff in a webpage (who would do that?), that means 7kbs, which is still lighter than the eCSStender. I’d advice a jquery (or any other library) version of it or an implementation in jquery code as default which would be greater.

    And an advice, I put these redundant CSS3 and CSS hack stuff in a seperate CSS (or seperate from all other ids’,classes) so when browsers update themselves and become CSS3 and W3 compliant, you can easily get rid of them.

    Copy & paste the code below to embed this comment.
  11. Aaron, thanks for the explanations in comment 32. I can see that eCSStender could be overkill in some situations, while being very useful in others. It’s good to consider it on a case-by-case basis.

    Copy & paste the code below to embed this comment.
  12. Regarding vendor prefixes, the following has been echoed many times:

    when browsers update themselves and become CSS3 and W3 compliant, you can easily get rid of them

    That will be true at some point, but depending on how far back you may need to support certain browser versions, you may have those prefixes in your stylesheets for some time. Just sayin’.

    Copy & paste the code below to embed this comment.
  13. So to clean up our CSS we use JS instead of vendor-specific properties? I don’t get it. It’s a waste of time IMO.

    Copy & paste the code below to embed this comment.
  14. I love the idea of ecsstender but I can’t get it to work in IE – specifically rounded corners or text-shadow. Works OK in webkit and mozilla. Should it work in IE or is that still under development?

    Copy & paste the code below to embed this comment.
  15. Mostly web sides users: approx 70% with IE <= 8.
    Even IE8 isn’t using CSS3. I’m testing some of my domains every few days and thing what’s happened with IE9? Or shell we get a other Firefox or Chrome or Safari …

    Copy & paste the code below to embed this comment.
  16. What you’ve assembled is great. It does make for clean use of CSS3. However, I’m taking exception to the premise that you present it in—specifically losing the need to use conditional forks.

    You are still forking, but you are using JS routines to sniff and detect browsers. A practice that you derided.

    And what happens when JS is disabled? Yes, I know. I know. In this day and age, darn near every site on the web breaks horribly with JS disabled, but the fact is that people do still do it.

    Have you considered doing what you do with JS, but doing it with a server-side language? Having it server-side would circumvent the client-side issue.

    I’m not diminishing what you’ve done. I think it’s great. It certainly makes life easier, through use of a standard libraries that degrade gracefully. What I’m taking issue with is the context of “no more forking” that you present it in.

    Copy & paste the code below to embed this comment.
  17. It won’t really be useful for us designers until we can guarantee that it will work on all browsers, our clients expect the site to look the same across all platforms and hence we cannot see this as a viable solution.

    A shame because I would really love to use this, and it would really make our lives allot easier. :)

    btw: you probably already know this but there are still issues with FF on your scripts homepage. :)

    Copy & paste the code below to embed this comment.
  18. I agree with comment #56… it’s a great idea, but to me the beauty of CSS3 is that we can do a great deal of what used to be done with Javascript instead with CSS3.  I can’t bring myself to use Javascript to cleanup my slightly messy CSS3, knowing that if someone were to visit my page without Javascript (think poor mobile phone support, people switching it off for security, etc.), they would not be able to see the shadows, animations, etc. that they might (depending on their browser) be able to see simply with pure CSS.

    I’d also rather not keep patching up old browsers with Javascript… the more we do this (as developers), the more we’re doing to keep those browsers around.  If the web was entirely broken in old versions of IE, would anyone continue to use it?  And if they did, would they really care about how sites looked, given that so many would have rendering issues?

    The idea (mentioned in prior comments in this thread) of a CSS pre-processor is a nice one though, it’d be great if something like this could be executed in that fashion (a bit like Sprockets?)

    Copy & paste the code below to embed this comment.
  19. i’ve been super excited to try this, but im looking at the Spoon demo site and it’s not working correctly in anything i view it in:

    -Chrome 6: animates and has rounded corners but no shadow
    -Safari 4: rounded corners with shadows, but no animation
    -FFox 3.6: no corners, no animation, no shadows
    -IE8:    no containing box at all, two small quote marks

    Copy & paste the code below to embed this comment.
  20. Well this still doesn’t work in FF. I’m on 3.6.12 / Linux and it’s a no go. Works great in Chrome/Linux though. I’m wondering… with this being such a large file compared to just a few extra lines in our CSS… Is it worth it? I’ve always thought that one of the main points of coding semantically was to reduce bandwidth. So, doesn’t this increase [it] greatly compared to a few extra (ugly) lines of code in our CSS? Am I missing something. Seems like a great tool but just not too sure about the size of the file?

    Copy & paste the code below to embed this comment.
  21. I like this idea a lot and found a similar attempt by Lea Verou. But i have similar concerns.
    1. Performance.
    2. We are watching evolution of support over browsers like linear-gradient in chrome 10 How is that taken care?

    Copy & paste the code below to embed this comment.