Jeff Croft

I’m a product designer in Seattle, WA. I recently worked at Simply Measured, and previously co-founded Lendle.

Some of my past clients include Facebook, Microsoft, Yahoo, and the University of Washington.

I’ve authored two books on web and interactive design and spoken at dozens of conferences around the world.

I’m currently accepting contract work and considering full-time opportunities.

Link // 10.23.2008 // 8:11 AM // 4 Comments

CSS Browser Selector

This seems like such a smart, elegant, simple solution to targeting browsers with CSS - I’m surprised no one thought of it before.

Visit site...


  1. 001 // Jeremy Ricketts // 10.23.2008 // 10:40 PM

    I saw that too and had the same reaction. Brilliant!

    Then I got to thinking. Let’s face it, “targeting different browsers” is shorthand for “targeting IE6” most of the time. Most of the time, if you’re decently proficient at CSS, you don’t need a separate stylesheet for IE7. But I digress.

    We’re talking about targeting IE.

    And there’s already a very efficient, supported way of doing this, right? Conditional browser comments. And as I see it, conditional browser comments have two advantages.

    1) No javascript needed! 2) Standards compliant browsers don’t have to parse CSS that is specific to only IE.

    Anyway, I’m still thinking about this issue. I would definitely agree that on a large complex site with multiple stylesheets, this proposed solution would be more elegant (you could keep all CSS in one stylesheet). On the other hand, a large complex site is exactly the type of project where you don’t want to make these performance sacrifices.

    So maybe it comes down to what matters more for the project: maintainability or performance. Thoughts?

  2. 002 // Matthew Pennell // 10.24.2008 // 1:17 AM

    I tend to agree with Jeremy - relying on scripting to class the body feels like overkill when 99% of the time all I want is to throw in some extra IE6 rules.

    I like the idea that Paul Hammond put out a few days ago - wrap your BODY tag in conditional comments and add the “ie” classname that way, so as not to require multiple stylesheets.

  3. 003 // Torbjørn Vik Lunde // 10.24.2008 // 5:20 AM

    If you first are going to use javascript of some kind I’d really prefer rather using IE7.js/IE8.js and just have one CSS for all the browsers.

  4. 004 // Jeff Croft // 10.26.2008 // 8:38 PM

    Jeremy, Matthew: I totally agree that conditional comments is the best way to handle browser detection — if you’re trying to target IE. Lately, I’ve been needing to target Safari, Gecko, and Opera a fair deal, too, and this works quite well for that.

Tags for this link