Skip to content

Instantly share code, notes, and snippets.

@mathiasbynens
Created May 25, 2011 17:33
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save mathiasbynens/991437 to your computer and use it in GitHub Desktop.
Save mathiasbynens/991437 to your computer and use it in GitHub Desktop.
Some more info on CSS hacks

There seems to be a difference between longhand properties (e.g. background-color) and shorthand properties (e.g. background). Some CSS hacks only work for one or the other. I’ve updated my test case to test these separately, and there are some interesting results.

The following hacks target IE8 but not IE9:

  • longhandproperty: \0value\0;
  • longhandproperty: \0value;

In practice, you might use these like so:

  • background-color: \0red\0;
  • background-color: \0red;

The following hacks target IE9 but not IE8:

  • shorthandproperty: \Bvalue\B;
  • shorthandproperty: \Bvalue;
  • shorthandproperty: \bvalue\b;
  • shorthandproperty: \bvalue;

In practice, you might use these like so:

  • background: \Bred\B;
  • background: \Bred;
  • background: \bred\b;
  • background: \bred;

Disclaimer: I wouldn’t recommend using these until more testing has been done.

@davidmurdoch
Copy link

I think we should promote/test the use of "tagging" the hacks with the targeted version. Like prop: value \0/IE9;

@mathiasbynens
Copy link
Author

Can’t use a-f0-9 after \b or \0 without a space in between.

— Simon Pieters

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