views:

1085

answers:

2

I’m currently using

@media screen and (-webkit-min-device-pixel-ratio:0) {
    example {}
    html:first-child example {}
}

to target Safari + Opera 9.2

Is there a safe way to target opera gte op 9.5 or lte op 10?
(for example it won't be picked up by an upcoming version of firefox)

By the way, type="text/opera" isn't working anymore

PS: I don't want JavaScript solutions.

A: 
* targets Opera 9 & below (and perhaps future versions) - valid HTML & invalid XHTML */

#dis[disabled="true"]+p {}

Source: http://perishablepress.com/press/2006/08/27/css-hack-dumpster/

Sarfraz
i tried it and it's not working (probably restricted to inputs)
Knu
v9.2 workingv10 not working (and that's what id like to target)
Knu
+3  A: 

That was hard but here it is. Works only in Opera gte 9.5 and lt 10.50:

@media all and (resolution = 0dpi) { // exclude Opera 10.50 and higher
  :root #box { // you need to append :root to all selectors to exclude Opera lt 9.5
    background: #f00;
  }
}
Sam Dark
im probably missing something - how is that targeting only opera?for example resolution seems to be supported by firefox 3.5https://developer.mozilla.org/En/CSS/Media_queries
Knu
Yes, it is targeting only Opera. FF ignores it. Just try.
Sam Dark
The key there is "0dpi" which seems to be "supported" but returned as true by all Opera versions < 10.50.
Sam Dark
i need to test it but it seems to be working // firefox use `:` instead of `=`
Knu
you didn't correctly pinpoint the culprit (it's related to http://www.w3.org/TR/css3-mediaqueries/#error-handling) // ill accept your solution if no one comes with something better and valid // you can use `(1)`
Knu
didn't ask for a **valid** css hack // it's better than nothing
Knu