Only CSS hack you’ll ever need, seriously.
Posted: March 1, 2007 at 10:24 pm | (20) CommentsWhile working on a few of my clients pages, I’ve always used other methods for CSS hacks but mostly using PHP to detect the remote user User-Agent and come up with the specific CSS. Until I’ve discovered this one:
You can actually have IE6 specific lines in CSS, it’s as simple as prefixing them with an underscore. Sure, you might start complaining “STANDARDS!!11!” – If I had to choose from a site that works fine in every browser and standards, I’ll go with the more working one. That’s not all! You can actually have lines that are both IE6 & IE7 specific in CSS by prefixing them with a dot.
So to sum it up, let’s say if I use a left margin that has to be 5px in Firefox/Opera, 6px for IE6 & 7px for IE7 – Here’s how I would do it:
margin-left: 5px; /* Left margin for all browsers, mainly Opera, Firefox, etc. */
.margin-left: 7px; /* Left margin of 7px that can be readable by both IE6 & IE7, now other still think it’s 5 while IE6 & IE7 think it’s 7 */
_margin-left: 6px; /* Only IE6 reads this and changes the value to 6px */
I have to admit I was pretty happy upon discovering this hack; I’ll sure be using it for a while now that I have found a pretty good one.
Do you have any of your own do not need loads of JavaScript and/or PHP code to work? Comment on!

We understand how difficult switching web hosting companies can get, that is why we assist all of our new clients by handling the complete moving procedure for free! We make switching hosts quick and easy for you, we'll move your files and your databases from your old host to our servers all for free.

Posted on: March 2, 2007 at 6:57 am
You don’t need any CSS hack, seriously.
I make quite complicated CSS designs and I’ve never used any hacks.
I do use conditional comments to load seperate css files for older versions of IE. It’s the only method that’s future proof.