photogal57
photogal57

Reputation: 13

CSS Conditional Statements

I know this is possible for css conditional formatting:

<!--[if !IE]>
   link/css style goes here
<![endif]-->

But is is possible to have an OR statement in there? Such as:

<!--[if !IE or !Opera]>
    link/css style goes here
<![endif]-->

Thanks in advance!

Upvotes: 1

Views: 439

Answers (1)

xec
xec

Reputation: 18024

Conditional Comments are an IE-specific feature, and will be ignored by opera etc.

They do support "or", however in the form of a pipe like so;

<!-- [if (IE 6)|(IE 7)]>
    this is only seen by IE 6 and 7
<![endif]-->

source: msdn

EDIT

As commented, it is indeed preferable to write cross-browser-compatible CSS when possible, and use conditional comments only as a last resort. To make life easier, be sure to avoid quirks mode and use feature detection over user agent sniffing. Check out the modernizr library which helps with the latter.

Upvotes: 5

Related Questions