Skip to content

Instantly share code, notes, and snippets.

@makasim
Created September 21, 2011 07:31
Show Gist options
  • Save makasim/1231469 to your computer and use it in GitHub Desktop.
Save makasim/1231469 to your computer and use it in GitHub Desktop.
IE hacks

Please use property-level hacks :)

The problem with conditional comments:

This requires to maintain IE-specific style in a separate file; What I learned from doing this is that you always forget to update the the IE-specific style as you modify the main style


The problem with .ie-[6789] classes:

This adds specificity to CSS rules:

.foo {
    color: red;
}
.ie .foo {
    color: green;
}
.foo {
    color: blue;
}

Guess the color of .foo on IE ? Once you added specificity somewhere you have to be as specific every where. So yere you have to do this:

.foo,
.ie .foo
{
    color: bleu
}

The problem with the "* html" hack:

It adds specificity to the rule (same as above)


The property hack have none of these problems:

.foo {
    color: green; /* applies to all browsers */
    *color: orange; /* applies to IE >= 7 (ignored by others in standard mode) */
    _color: red; /* applies to IE >= 6 (ignored by others in standard mode) */
}

As you should have only a few different properties between IE and others, this is perfectly fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment