Comments on: user-select https://css-tricks.com Tips, Tricks, and Techniques on using Cascading Style Sheets. Mon, 10 Sep 2018 16:56:15 +0000 hourly 1 https://wordpress.org/?v=6.1.1 By: Nelson https://css-tricks.com/almanac/properties/u/user-select/#comment-1652072 Mon, 10 Sep 2018 16:56:15 +0000 http://css-tricks.com/?page_id=15568#comment-1652072 I’m trying to make some text unselectable and un-copy/pastable. Adding user-select: none; does indeed accomplish that when I test with Chrome and a plain text editor (Atom). But when I paste into Microsoft Word, I get all the text I did not want to select/copy/paste. I’m not familiar with how the clipboard works but this seems odd. Is there a way to prevent text from being copied from the browser and pasted in Microsoft Word?

]]>
By: Jonathan Schofield (@schofeld) https://css-tricks.com/almanac/properties/u/user-select/#comment-1644259 Wed, 04 Jul 2018 10:56:47 +0000 http://css-tricks.com/?page_id=15568#comment-1644259

This is useful in situations where you want to provide an easier/cleaner copy-paste experience for users

Turns out it’s also useful for Facebook who use it as a #darkpattern to block copy/pasting of Facebook posts when not logged in >:(

]]>
By: Tracy Goodwin https://css-tricks.com/almanac/properties/u/user-select/#comment-1616240 Mon, 19 Feb 2018 16:05:02 +0000 http://css-tricks.com/?page_id=15568#comment-1616240 Thank you! I know its been a while since this was wrote but I turned off copy and paste because of other sites stealing my work and claiming it was theirs. But then people couldn’t copy links I was giving them and blogger changed its look and I didn’t know how to turn it off. With one word they can do it again :)

]]>
By: Abdullah Ahmed https://css-tricks.com/almanac/properties/u/user-select/#comment-1609598 Tue, 27 Jun 2017 14:35:02 +0000 http://css-tricks.com/?page_id=15568#comment-1609598 In reply to Gabo.

But you can use pointer-events: none.

The pointer-events property allows for control over how HTML elements respond to mouse/touch events – including CSS hover/active states, click/tap events in Javascript, and whether or not the cursor is visible.

]]>
By: Marcel https://css-tricks.com/almanac/properties/u/user-select/#comment-1605673 Wed, 21 Dec 2016 23:47:06 +0000 http://css-tricks.com/?page_id=15568#comment-1605673 If you’re using Cordova and iOS you will need to do additional work to suppress the text selection bubble. http://stackoverflow.com/questions/32812308/ios-cordova-long-press-shows-text-select-magnifying-glass-even-with-text-selecti

]]>
By: Mathias Bynens https://css-tricks.com/almanac/properties/u/user-select/#comment-1603952 Wed, 07 Sep 2016 14:00:39 +0000 http://css-tricks.com/?page_id=15568#comment-1603952 In reply to Mathias Bynens.

Sorry, I meant Chrome 53+, and Opera 40.

]]>
By: Mathias Bynens https://css-tricks.com/almanac/properties/u/user-select/#comment-1603951 Wed, 07 Sep 2016 13:59:36 +0000 http://css-tricks.com/?page_id=15568#comment-1603951 -webkit-user-select: all; /* Chrome 49+ */

…should be…

-webkit-user-select: all; /* Chrome 50+ */

]]>
By: roark https://css-tricks.com/almanac/properties/u/user-select/#comment-1603928 Tue, 06 Sep 2016 04:36:05 +0000 http://css-tricks.com/?page_id=15568#comment-1603928 In reply to anon.

There are tons of valid non-DRM use cases for this feature. In my personal case building a custom WYSIWYG editor. Being able to control user selection is an application level feature needed for the types of rich apps being built today.

Unfortunately, there it still isn’t standardized to a high degree across browsers. Especially when contentEditable becomes involved.

]]>
By: anon https://css-tricks.com/almanac/properties/u/user-select/#comment-1598546 Sat, 12 Dec 2015 11:58:07 +0000 http://css-tricks.com/?page_id=15568#comment-1598546 Basically a DRM feature, I’ve just found a site abusing this. All the crud on the page can be selected, but nothing in the article. I want to view a bit of the source to see how their web2.0 malware works, but found they are hindering that.

FF, and all the modern browsers, are just proprietary application delivery platforms. And for that reason they suck in ways that Windows does. The user should be in control, sites should not be able to do stupid things without the user specifically allowing it.

]]>
By: Pavel https://css-tricks.com/almanac/properties/u/user-select/#comment-1597319 Thu, 01 Oct 2015 14:45:33 +0000 http://css-tricks.com/?page_id=15568#comment-1597319 In reply to Gabo.

Seems like “user-select:none” does not work in Android Browser prior to version 4.1
But i’ve not found any official proof for that.
I’ve tested this example http://jsfiddle.net/u88wbh10/4/ in different versions of Android Browser:
Samsung mobile device with android os 4.1.2 – works.
SE Xperia mobile device with android os 4.0.4 – does’t work.
Both android versions have the same version of webkit built-in.
There are several threads on the stackoverflow pointing to this issue. For example: http://stackoverflow.com/questions/5107651/android-disable-text-selection-in-a-webview
Although the MDN & canisue.com shows the support for “user-select” from the android 2.1:
https://developer.mozilla.org/en-US/docs/Web/CSS/user-select#Browser_compatibility
http://caniuse.com/#search=user-select
Anyone experienced the same problem?

]]>
By: Mark https://css-tricks.com/almanac/properties/u/user-select/#comment-1596640 Thu, 27 Aug 2015 07:32:53 +0000 http://css-tricks.com/?page_id=15568#comment-1596640 Okay, as an example of cmd influence on coding, consider this code to reveal carat behavior (sorry, limitations here, you’ll have to close the obvious spaces in following code in your device preview)


PRE and CODE cannot display literal carat symbols. Element tags for carats are hand-coded &lt ; ‘<‘ left carat and &gt ; ‘>’ right carat.

The display reflex for select-none behavior is almost identical. Attach pointer-events to parent PRE, and attach user-select to child CODE (each line a separate CODE tag) and parent selection happens with outside drag in/across. Cmd-based interference, with nothing outside visibly selected, paste selection reveals inclusion of last pre-PRE character invisibly included in copied selection. Behavior of counter and code is as not selectable from inside PRE or attributed CODE counter. Therefore, the google prettify.js uses attribution in some way as our missing hack would. Which will be another blog post, here at CSS-Tricks.

]]>
By: Mark https://css-tricks.com/almanac/properties/u/user-select/#comment-1596638 Thu, 27 Aug 2015 07:04:10 +0000 http://css-tricks.com/?page_id=15568#comment-1596638 Hey gang, CSS ‘pointer-select: none;’ has exactly the same behavior, where selection of anything before or after ‘select none’ tag content enables selection of all content in the selection area. There is a cmd processing hack here (somewhere), something CSS-Tricks should be able to bring to light: the parent selection must be made to react in a certain way to the child ‘select none’ element. Prettify.js (“google.code.prettify”) handles this sort of focus management nicely. HTML/CSS workaround?


pre { counter-reset: line; white-space: pre-wrap; }
code { counter-increment: line; }
pre code:before { content: counter(line); margin-right: 3rem; pointer-events: none; }
pre code:before { -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; }

pre { counter-reset: line; }
code { counter-increment: line; }
code:before { content: counter(line); user-select: none; }

]]>
By: Malcolm Ocean https://css-tricks.com/almanac/properties/u/user-select/#comment-1593863 Tue, 14 Apr 2015 15:13:40 +0000 http://css-tricks.com/?page_id=15568#comment-1593863 I have a UI with rows of content that have “buttons” in them too, and I was trying to prevent the buttons from having their text copied too, when people tried to copy the content. What I did was change the text I didn’t want selected from being part of the element to being created by a css :before pseudoelement. It worked like a charm!

.item a.nevermind-x:before {
  content: "\2715";
}

]]>
By: JK https://css-tricks.com/almanac/properties/u/user-select/#comment-1428006 Mon, 24 Mar 2014 02:04:19 +0000 http://css-tricks.com/?page_id=15568#comment-1428006 I have pages with a lot of user-created text. Users often want to “select all” to paste into email, etc. The text they want is across several long “contenteditables” (think Google Doc but multiple docs in on eweb page). “Select all” makes the most sense, since select and drag makes you have to scroll a lot and also the selection stops when you reach the boundary of the contenteditable.

But “select all” also selects the “chrome” of the page (nav, etc.) which they don’t want.

You’d think this “user-select” would be what I want, but the way it works (FF at least) is that “select all” selects the user-select:none text.

I suppose there is a danger of making it too easy for the devs to make it too hard for users to select text. Still, it might be a nice thing if we could figure it out.

]]>
By: jim https://css-tricks.com/almanac/properties/u/user-select/#comment-1427075 Sun, 23 Mar 2014 23:01:31 +0000 http://css-tricks.com/?page_id=15568#comment-1427075 I would prefer the surfer hone their skills with a mouse to cluttering up the already obfuscatiousness of CSSx-de-jour. Just sayin… :-)

]]>