Make CSS apply only for Opera 11?

Tomkay picture Tomkay · Jan 10, 2011 · Viewed 9.8k times · Source

Is there a way to make some CSS rules apply only for Opera (11)?

Answer

Knu picture Knu · Jan 18, 2011

I love challenges!
It took me some time but I finally found it:

body {background:0} /* default */
@media not screen and (1) {
body {background:red} /* OP 11 */
}
@media not screen and (orientation) {
body {background:green} /* for the earlier versions of Opera that pick the first media query's rule + chrome/safari */
}

browsers tested:

  • red: Opera 11
  • green: Opera 10 and 10.5 + WebKit browsers
  • none: Opera 9.26 + Firefox 3.6 + IE9

It's related to the error-handling and also the fact that NOT negates the global result (WebKit browsers don't evaluate orientation correctly without a valid value). Since orientation is supported in presto 2.7 the second media query is FALSE.

The false orientation hack sounds like a good name to me.