문제

Is it a good idea to put all conditional CSS rules in one conditional stylesheet instead of making multiple stylesheets for different versions of IE?

Example:

<!--[if IE]>
 <link rel="stylesheet" type="text/css" href="all-ie-only.css" />
<![endif]-->

Content of all-ie-only.css:

selector {  
   color : green\9; /* IE8 and below */  
  *color : yellow; /* IE7 and below */  
  _color : orange; /* IE6 */
}

Using IE underscore/asterisk hacks see: http://webstandardstips.com/2008/11/18/css-hacks-for-ie-only-style-rules/

도움이 되었습니까?

해결책

The advantage I see in this technique is that you have just one style sheet in your server which may be easier to maintain.

The disadvantage is that users will need to download the whole file which may be 3 times bigger hence taking more time to download and to process.

Appart from that, I think there's no other issues with it.

다른 팁

Yes, it's fine. I think it becomes a question of how many items the file has to hold. If you're just overriding 1/ 2/ 3 things, the single file makes much more sense. At some arbitrary point (10 things? 100 lines of code), I'd say the trade-off swings the other way and it's simpler to maintain the three files.

What if IE 10 comes along and invalidates some of these hacks? I think this approach defeats the purpose of using IE conditional comments in place of hacks, that being more of a future-proof implementation.

Plus is there any advantage, besides slightly easier maintenance, and negligible HTML file size savings? As LuckyShot mentioned, it's already a detriment for IE users which will have to download a larger browser-specific file.

this is right to use this for all IE Version. but when you use this then you will find that, this is not w3c valid. Generally IE create problem.Safari, Chrome , and Firefox will run these good.I think this is better idea to use one Css for all IE version.

As long as it works and its valid, then it doesn't really matter whether its in 1 file or 3, its just personal preference.

Personally, I prefer to have a seperate sheet for each IE version (if needed), as I find it easier to organise.

Like I said, if its W3C complient (god, don't we just love them), then its all good.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top