Search code examples
cssinternet-exploreralternate

alternative CSS sheets for IE?


I have a question about CSS coding practices. IE often requires hacks or workarounds to get things looking right, and there are two different ways of doing things:

  1. Put everything in one big CSS file
  2. Create two CSS files and have it load depending on the browser that the user is using

I'm thinking the second one makes more sense, but is there any reason not to do this? Which is more common?


Solution

  • The only argument against two CSS files would be that on first open of your page it'll generate one extra HTTP request.

    However, once the browser cache is populated with the local copy of these files, this concern is removed.

    On the other hand, having IE styles separately means users on other browsers won't load them. Also, there's clear separation between the main styles, and the hacks, which means that with the adoption of IE9 you will be in a position to deprecate the hacks CSS easily down the road by just removing that file, instead of modifying the main CSS file.