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!

Matt Cain
  • 5,638
  • 3
  • 36
  • 45
photogal57
  • 13
  • 6
  • 3
    Keep in mind IE (and only old versions of it) is the only browser that supports these statements. It is best to write cross-browser CSS – Benjamin Gruenbaum Mar 20 '13 at 13:36
  • Also, while this is a bit old, this closely related question might provide additional insight http://stackoverflow.com/questions/4332117/how-to-write-specific-css-for-mozilla-chrome-and-ie , also related http://stackoverflow.com/questions/454863/what-is-better-css-hacks-or-browser-detection?rq=1 – Benjamin Gruenbaum Mar 20 '13 at 13:39

1 Answers1

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.

xec
  • 17,349
  • 3
  • 46
  • 54
  • +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) – Benjamin Gruenbaum Mar 20 '13 at 13:42