views:

248

answers:

5

Which css hacks for IE 6 and 7 are future proof? i mean if i use then then they would never create any problem and their patch will never be implemented?

manage 2 css one for all and one for IE is time consuming and it adds one extra style sheet also. and if any hack can solve problem within main css then it's a timesaver and when multiple people work on same project then most of time we forgot to make change in conditional css too.

i'm not asking about condition stylesheet

+16  A: 

none.
Use IE conditional comments to insert your per-version (no pun intended .. well maybe a little) styles..


[update]
Additional notes to you altered question. It might be time consuming but it is the best-practice (btw many of the hacks are not valid css)..

Using hacks can never be guaranteed, even for the same major versions of a browser .. It is unlikely that they will fix a css bug in IE6 in future minor releases, but still you can not be 100% certain..

There is an alternative (perhaps more time consuming at first), the IE comments i mentioned, but it is truly the best practice...

Besides, think about the other coders in your team who all must know, understand and remember in the future the same hacks.. Over time it will become more time consuming to maintain the hacks than to maintain distinct versions of the offending rules in other files..

Gaby
+1 for the pun intended or not.
Joel Etherton
can we use conditional in .css
metal-gear-solid
I doubt the part in paranthesis, at least the "intended" part. Anyways, i can only add: none of the hacks will work in any future IE version. Your only hope is that pre-IE8 versions will die a fast death and disappear soon but i fear they won't.
dbemerlin
@Jitendra, not inside the .css file.. but you should keep different versions separate anyway ..
Gaby
+1  A: 

Generally speaking, none are. But nor should they be, special-case coding for spesific browsers isn't a good idea.

If you -do- have to make special-case coding, then your best bet is to use a library like jQuery, and use one of their feature-tests. Don't do "if not IE6", instead do "if not supports-rounded-corners"

Agrajag
+1  A: 

I can't think about a property starting with an underscore in the future.

_background: #ff0000;
erenon
i think ot will work forever in IE6
metal-gear-solid
+1  A: 

Hacks are hacks, there is no guarantee whatsoever whether or not they will be future proof. The point is that you should minimize the use of hacks as much as possible, the reason is simple, they can't be future-proof. Don't you see any differences between the hacks of IE6, IE7 and IE8, they all have different hacks, did not retain all hacks from previous versions. Same is true for other browsers.

Sarfraz
+1  A: 

Anything that involves overriding a CSS attribute later in the code is just following the CSS standard, and is therefore future-proof.

body {
   background: url('background.jpg') center;
   background: url('background-top.jpg') top, url('background-bottom.jpg') bottom;
}

However, this only works when using features that aren't available in older browsers, and not when dealing with browser-specific bugs. To ensure specific versions of your CSS are used by specific versions of Internet Explorer, use conditional comments.

<head>
    ...
    <!--[if lt IE 8]><link rel="stylesheet" type="text/css" src="ie7.css" /><![endif]-->
    <link rel="stylesheet" type="text/css" src="generic.css" />
</head>
Samir Talwar