views:

121

answers:

6

Which is the CSS hack you use most often and which one do you avoid using?

I am asking this question so that I can understand different views of different people about CSS hacks and also understand which hacks are good and which ones are not.

+1  A: 

Most used - clear fix

Most hated - !important rules because they are an indication that the stylesheet is probably not organized properly. It also means that some styles are too general that they ought to be. Not good for performance either.

Chetan Sastry
+3  A: 

Not technically a hack, but I often include conditional comments to target IE 7-:

<!--[if lte IE 7]>
<link href="ie7.css" />
<![endif]-->

I actually get away without using many hacks.

Joel Potter
A: 

I mostly use min-height hack and avoid using underscore trick something like _margin that targets IE6.

Sarfraz
then css will not be valid
metal-gear-solid
A: 

I've found that if I use the XHTML 1.0 strict doctype, mostly things just work... That said, I don't really do anything fancy... But a nice minimalistic site like SO would be pretty easy to design sans hacks...

dicroce
A: 

PNG transparency in IE6 with AlphaImageLoader()...

IE versions >6 and Firefox and Chrome all support full 8-bit transparent PNGs, but for IE6 compatibility you have to do the above css hack. Your CSS file will no longer validate but if you rely on transparent PNGs like I do... it's worth it.

advs89
A: 

Most Used: Negative Margins

contactmatt
Is that a hack or feature? ;)
Joel Potter
Lol, depends how its used.
contactmatt