Is there user-select for Opera 10.62 and IE9?
Solution 1
Did you try using ::selection {color:currentColor;background:transparent}
?
For Firefox you can use ::-moz-selection
.
https://developer.mozilla.org/En/CSS/::selection
http://msdn.microsoft.com/en-us/library/ff974109(v=VS.85).aspx
http://reference.sitepoint.com/css/pseudoelement-selection
// update //
There's also the unselectable property.
Solution 2
You can use combination of -webkit-user-select: none;
, -moz-user-select: none;
and specific property unselectable="on"
, as I described here:
How to make text unselectable on HTML page
Solution 3
user-select isn't a standard CSS3 property, which is why there is no user-select or -o-user-select or -ms-user-select. It used to be in the old user interface spec, but that was superseded by the Basic UI spec. It will likely never be implemented by either browser, unless it is added back to the spec.
User selection is a behaviour rather than a style, so it is best to use JavaScript. As Knu mentions above, you can use unselectable instead.
Related videos on Youtube
Tower
Updated on May 05, 2022Comments
-
Tower about 2 years
I have been trying to apply
user-select
for both Opera 10.62 and IE9 without success. I can't/won't bind events with JavaScript thatpreventDefault()
, because there are so many places to be set unselectable and I still need to retain selections in several places. In fact, I want the default behavior to be unselectable for the whole document, and as for that I have set the following in my stylesheet:* { -o-user-select: none; -webkit-user-select: none; -moz-user-select: -moz-none; -khtml-user-select: none; -ms-user-select: none; user-select: none; }
Everything works great with Firefox 4, Chrome 7 and Safari 5. Only IE9 and Opera 10.62 are not working as I would like them to. Any ideas?
PS: I'm targeting modern browsers.
-
Tower over 13 yearsYeah, but that's not really good because it just hides the selection. You can still drag the selection and copy it.
-
Knu over 13 yearscheck my update - and read developer.mozilla.org/en/CSS/-moz-user-select "Controls the appearance (only) of selection. This does not have any affect on actual selection operation."
-
Tower over 13 yearsBut what's awful is that children do not inherit
unselectable
. So, I would need to apply that for pretty much everything, manually. I have a application with text here and there, and by default I want everything unselectable. Only when I specifically want selections, I will define them. This approach is not implementable withunselectable
. Also, the property works if you begin the selection on that element. Ctrl + A, etc. will work withunselectable
. -
ajcw over 13 yearsA combination of the -user-select properties and unselectable worked a treat for me cross-browser.
-
Tim Down about 13 yearsActually Opera does have
-o-user-select
. Not sure which version but I think 10.6 had it. -
David Storey about 13 years@Tim Down: I'm pretty sure Opera doesn't support -o-user-select. It isn't listed in our spec opera.com/docs/specs/presto29/css/o-vendor and it doesn't show up in Opera Dragonfly either.
-
Tim Down about 13 years@dstorey: A quick test would suggest you're right: jsfiddle.net/MguY2. I did test this a while ago and thought it was supported, but it seems I was wrong.
-
McTrafik about 12 years-ms-user-select exists in IE10. Not 9.
-
acme about 12 yearsShouldn't
color: currentColor
becolor: inherit
? -
Knu about 12 years@acme you want the current color of the element (not of one of his ancestors).
-
acme about 12 yearsAh ok, I learned something new today: I didn't knew there is the
currentColor
keyword. -
SexyBeast almost 11 yearsIf suppose there is a
span
in adiv
, and thediv
has a gradient as a background color, will this still work for the text inside thespan
? -
awe about 10 yearsWow! I thought IE11 was supposed to support the official standards without the need for browser specific hacks! When they introduced support for this, why not go directly on the standard without browser prefix ??!!! (And yes - I tested in IE 11; it only works with the
-ms-
prefix) -
dude over 9 yearsdisable user-select with CSS will not work in IE 8 & 9