{"id":15568,"date":"2011-12-14T08:55:20","date_gmt":"2011-12-14T15:55:20","guid":{"rendered":"http:\/\/css-tricks.com\/?page_id=15568"},"modified":"2016-07-25T13:34:01","modified_gmt":"2016-07-25T20:34:01","slug":"user-select","status":"publish","type":"page","link":"https:\/\/css-tricks.com\/almanac\/properties\/u\/user-select\/","title":{"rendered":"user-select"},"content":{"rendered":"
The This is useful in situations where you want to provide an easier\/cleaner copy-paste experience for users (not have them accidentally text-select useless things, like icons or images). However it’s a bit buggy. Firefox enforces the fact that any text matching that selector cannot be copied. WebKit still allows the text to be copied if you select elements around it. <\/p>\n You can also use this to enforce that an entire element gets selection:<\/p>\n Here’s some demos of those:<\/p>\n See the Pen user-select demo<\/a> by Chris Coyier (@chriscoyier<\/a>) on CodePen<\/a>.<\/p>\n There was no spec for this property for quite a while, but now is covered under CSS Basic User Interface Module Level 4<\/a>. <\/p>\n The default value is In other words, it intelligently cascades and resets to a sensical state. It looks like maybe<\/em> this feature could be used to make pseudo elements selectable, but no final word yet.<\/p>\n Firefox supports Internet Explorer also supports<\/a> a so-far-proprietary value, user-select<\/code> property in CSS controls how the text in an element is allowed to be selected. For example, it can be used to make text unselectable.<\/p>\n
.row-of-icons {\r\n -webkit-user-select: none; \/* Chrome all \/ Safari all *\/\r\n -moz-user-select: none; \/* Firefox all *\/\r\n -ms-user-select: none; \/* IE 10+ *\/\r\n user-select: none; \/* Likely future *\/ \r\n}<\/code><\/pre>\n
.force-select { \r\n -webkit-user-select: all; \/* Chrome 49+ *\/\r\n -moz-user-select: all; \/* Firefox 43+ *\/\r\n -ms-user-select: all; \/* No support yet *\/\r\n user-select: all; \/* Likely future *\/ \r\n}<\/code><\/pre>\n
auto<\/code>, which makes selection happen normally as you expect. “Normally” is a bit complicated. It’s worth quoting from the spec here:<\/p>\n
\n
\n
none<\/code>\n <\/li>\n
contain<\/code>\n <\/li>\n
all<\/code>, the computed value is
all<\/code>\n <\/li>\n
none<\/code>, the computed value is
none<\/code>\n <\/li>\n
text<\/code>\n <\/li>\n<\/ul>\n<\/blockquote>\n
Older\/Proprietary<\/h3>\n
-moz-none<\/code>, which is just like none except that it means sub-elements can override the cascade and become selectable again with
-moz-user-select: text;<\/code> As of Firefox 21, none behaves like
-moz-none<\/code>.<\/p>\n
element<\/code>, in which you can select text inside the element but the selection will stop at the bounds of that element.<\/p>\n
More Information<\/h3>\n