views:

130

answers:

2

I came across this strange bit of CSS tonight...

display: inline !ie;

Now I've created and seen a lot of CSS and I have never seen this before or its magical powers.

You can add "!ie" at the end of any rule and it will only be applied by M$ Internet Explorer 6 & 7

Can anyone shed any light on this WTF?

+3  A: 

At a guess, I would say that Internet Explorer tries to recover from what is quite clearly an error. The following would also work:

display: inline !pudding;

The specification says that if an invalid value is specified or an error occurs in a rule it should be ignored. It looks like most browsers stick to this but IE recovers for this specific situation.

In some cases, user agents must ignore part of an illegal style sheet. This specification defines ignore to mean that the user agent parses the illegal part (in order to find its beginning and end), but otherwise acts as if it had not been there.

http://www.w3.org/TR/CSS21/syndata.html#parsing-errors

Andy E
+8  A: 

Internet Explorer 7 and below have a few quirks related to the !important declaration, which is supposed to give a value higher importance than normal.[3] IE7 and earlier accept virtually any string in place of important and process the value normally, while other browsers will ignore it.

Taken from !Important Quirks section in CSS Filter - Wikipedia

Anthony Forloney