This is an experimental technology
Check the Browser compatibility table carefully before using this in production.
The user-select
CSS property controls whether the user can select text. This doesn't have any effect on content loaded as chrome, except in textboxes.
/* Keyword values */ user-select: none; user-select: auto; user-select: text; user-select: contain; user-select: all; /* Global values */ user-select: inherit; user-select: initial; user-select: unset; /* Mozilla-specific values */ -moz-user-select: none; -moz-user-select: text; -moz-user-select: all; /* WebKit-specific values */ -webkit-user-select: none; -webkit-user-select: text; -webkit-user-select: all; /* Doesn't work in Safari; use only "none" or "text", or else it will allow typing in the <html> container */ /* Microsoft-specific values */ -ms-user-select: none; -ms-user-select: text; -ms-user-select: element;
Initial value | auto |
---|---|
Applies to | all elements |
Inherited | no |
Media | visual |
Computed value | as specified |
Animation type | discrete |
Canonical order | the unique non-ambiguous order defined by the formal grammar |
none
Selection
object can contain these elements. Starting with Firefox 21, none
behaves like -moz-none
, so selection can be re-enabled on sub-elements using -moz-user-select: text
.auto
The computed value of auto is determined as follows:
::before
and ::after
pseudo elements, the computed value is none
contain
user-select
on the parent of this element is all
, the computed value is all
user-select
on the parent of this element is none
, the computed value is none
text
text
-moz-none
Selection
object can contain these elements. Selection can be re-enabled on sub-elements using -moz-user-select: text
. Starting with Firefox 21, none
behaves like -moz-none
.all
contain
element
(IE-specific alias)Note: One of the differences between browser implementations is inheritance. In Firefox, -moz-user-select is not inherited by absolutely positioned elements, but in Safari and Chrome, -webkit-user-select is inherited by those elements.
Note: CSS UI 4 renames user-select: element to contain.
auto | text | none | contain | all
<p>You should be able to select this text.</p> <p class="unselectable">Hey, you can't select this text!</p>
.unselectable { -moz-user-select: none; -webkit-user-select: none; -ms-user-select: none; user-select: none; }
Specification | Status | Comment |
---|---|---|
CSS Basic User Interface Module Level 4 The definition of 'user-select' in that specification. | Working Draft | Initial definition. Also defines -webkit-user-select as a deprecated alias of user-select . |
Desktop | ||||||
---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | |
Basic support | 54
|
12
|
Yes
|
10 | 15
|
3.1
|
auto
|
Yes | 12 | Yes | 10 | Yes | Yes |
all
|
Yes | 12 | Yes | 10 | Yes | Yes |
none
|
Yes | 12 | 21
|
10 | Yes | Yes |
text
|
Yes | 12 | Yes | 10 | Yes | Partial
|
contain
|
No | 12
|
No | Yes
|
No | No |
Mobile | |||||||
---|---|---|---|---|---|---|---|
Android webview | Chrome for Android | Edge Mobile | Firefox for Android | Opera for Android | iOS Safari | Samsung Internet | |
Basic support | 54
|
54
|
12
|
Yes
|
14
|
3.2
|
6.0
|
auto
|
Yes | Yes | 12 | Yes | Yes | Yes | Yes |
all
|
Yes | Yes | 12 | Yes | Yes | Yes | Yes |
none
|
Yes | Yes | 12 | 21
|
Yes | Yes | Yes |
text
|
Yes | Yes | 12 | Yes | Yes | Partial
|
Yes |
contain
|
No | No | 12
|
No | No | No | No |
::selection
Selection
object.
© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/CSS/-ms-user-select