expression() Microsoft Extension

Test of Filter

This text will be green if the rule has been applied.

Code Syntax


#testElement {
   color: expression('#00cc00');
   }
         

Browser Support / Behaviour

Applied By

Not Applied By

Destroyed

Unknown

Special Notes / Browser Specific Behaviour

expression() will assign the value returned by a block of arbitrary Javascript to the CSS property it is associated with. Only IE on Windows implements expression(). Behavioral Extensions - a proposed addition to CSS - would do the same thing but work on this appears to have stalled or stopped completely.

This method can be helpful in extending CSS support in IE on Windows. For instance, implementing max-width (or min-width, max-height, and min-height with minor adjustments to the code shown). Many more uses are probably possible. It can also be used to hide styles from browsers that don't recognize the expression() extension as is done in the example on this page.

This method will work even if the user has turned off Javascript support (which is, of course, a potential security problem).

Possible Validating Alternatives

If you simply want to hide styles from everything but IE 5.0 - 6.x, you could use IE conditional comments. An all-CSS alternative (if you ignore IE4 Windows) would be to define the IE Windows styles using the Star HTML hack inside a @media all block.

More information