1

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!

2

1 Answer 1

5

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.

Sign up to request clarification or add additional context in comments.

1 Comment

+1 for teaching me something :) Had no idea I could do that. I'd just like to add it is generally better to write CSS that works in all browsers to begin with (or, degrades gracefully)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.