IE Conditional Comments

CSS Add comments

Even that IE has terrible CSS support it still have one nice little hack to help develop CSS’s and other stuff too.
Instead using browser detect in JavaScript there is Conditional Comments to do same trick.

Syntax
<!–[if IE]><style type=”text/css”> /*<![CDATA[*/ body { color: #000000; } /*]]>*/ </style> <![endif]–>

Applied By

* Win IE 5.0 - 6.x

<!–[if ( ! )* ( comparison )* IE ( version number )* ]> HTML content to parse if the condition is true goes here <![endif]–>

By wrapping an embedded stylesheet in conditional comments, you can make the styles apply only to IE5+ on Windows. Below are a number of ways to write conditional comments to target specific combinations of IE5+ browsers:

<!–[if gte IE 5]> IE 5.0 - 6.x

<!–[if IE 5]> IE 5.0

<!–[if IE 5.5000]> IE 5.5

<!–[if IE 6]> IE 6.0

<!–[if gte IE 5.5000]> IE 5.5 - 6.x

<!–[if lt IE 6]> IE 5.0 - 5.5

About Conditional Comments

One Response to “IE Conditional Comments”

  1. Helen Says:

    Not having to filter for browsers would be nicer though :)

Leave a Reply

Check Spelling
Activate Spell Check while Typing
WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in