Search code examples
cssopera

Make CSS apply only for Opera 11?


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


Solution

  • 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.