Web/CSS/user-select

From Get docs


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;

Note: user-select is not an inherited property, though the initial auto value makes it behave like it is inherited most of the time. WebKit/Chromium-based browsers do implement the property as inherited, which violates the behavior described in the spec, and this will bring some issues. Until now, Chromium chooses to fix the issues, make the final behavior meets the specifications.


Syntax

none
The text of the element and its sub-elements is not selectable. Note that the Selection object can contain these elements.
auto
The used value of auto is determined as follows:
  • On the ::before and ::after pseudo elements, the used value is none
  • If the element is an editable element, the used value is contain
  • Otherwise, if the used value of user-select on the parent of this element is all, the used value is all
  • Otherwise, if the used value of user-select on the parent of this element is none, the used value is none
  • Otherwise, the used value is text
text
The text can be selected by the user.
all
The content of the element shall be selected atomically: If a selection would contain part of the element, then the selection must contain the entire element including all its descendants.  If a double-click or context-click occurred in sub-elements, the highest ancestor with this value will be selected.
contain
Enables selection to start within the element; however, the selection will be contained by the bounds of that element.
element ' (IE-specific alias)
Same as contain. Supported only in Internet Explorer.

Formal definition

Initial value auto
Applies to all elements
Inherited no
Computed value as specified
Animation type discrete

Formal syntax

auto | text | none | contain | all

Examples

HTML

<p>You should be able to select this text.</p>
<p class="unselectable">Hey, you can't select this text!</p>
<p class="all">Clicking once will select all of this text.</p>

CSS

.unselectable {
  -moz-user-select: none;
  -webkit-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

.all {
  -moz-user-select: all;
  -webkit-user-select: all;
  -ms-user-select: all;
  user-select: all;
}

Result

Specifications

Specification Status Comment
CSS Basic User Interface Module Level 4The definition of 'user-select' in that specification. Working Draft Initial definition. Also defines -webkit-user-select as a deprecated alias of user-select.

Browser compatibility

Update compatibility data on GitHub

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
user-select

Chrome Full support 54


Full support 54


Full support 1

Prefixed'

Prefixed' Implemented with the vendor prefix: -webkit-

Edge Full support 12

Prefixed'

Full support 12

Prefixed'

Prefixed' Implemented with the vendor prefix: -ms- Full support 12

Prefixed'

Prefixed' Implemented with the vendor prefix: -webkit-

Firefox Full support 69


Full support 69


Full support 49

Prefixed'

Prefixed' Implemented with the vendor prefix: -webkit- Full support 1

Prefixed'

Prefixed' Implemented with the vendor prefix: -moz- Full support 44

Prefixed' Disabled'

Prefixed' Implemented with the vendor prefix: -webkit- Disabled' From version 44: this feature is behind the layout.css.prefixes.webkit preference (needs to be set to true). To change preferences in Firefox, visit about:config.

IE Full support 10

Prefixed'

Full support 10

Prefixed'

Prefixed' Implemented with the vendor prefix: -ms-

Opera Full support 15

Prefixed'

Full support 15

Prefixed'

Prefixed' Implemented with the vendor prefix: -webkit-

Safari Full support 3

Prefixed'

Full support 3

Prefixed'

Prefixed' Implemented with the vendor prefix: -webkit- No support 2 — 3

Prefixed'

Prefixed' Implemented with the vendor prefix: -khtml-

WebView Android Full support 54


Full support 54


Full support ≤37

Prefixed'

Prefixed' Implemented with the vendor prefix: -webkit-

Chrome Android Full support 54


Full support 54


Full support 18

Prefixed'

Prefixed' Implemented with the vendor prefix: -webkit-

Firefox Android Full support 49

Prefixed'

Full support 49

Prefixed'

Prefixed' Implemented with the vendor prefix: -webkit- Full support 4

Prefixed'

Prefixed' Implemented with the vendor prefix: -moz- Full support 44

Prefixed' Disabled'

Prefixed' Implemented with the vendor prefix: -webkit- Disabled' From version 44: this feature is behind the layout.css.prefixes.webkit preference (needs to be set to true). To change preferences in Firefox, visit about:config.

Opera Android Full support 14

Prefixed'

Full support 14

Prefixed'

Prefixed' Implemented with the vendor prefix: -webkit-

Safari iOS Full support 3

Prefixed'

Full support 3

Prefixed'

Prefixed' Implemented with the vendor prefix: -webkit-

Samsung Internet Android Full support 6.0


Full support 6.0


Full support 1.0

Prefixed'

Prefixed' Implemented with the vendor prefix: -webkit-

all Chrome

Full support 53

Edge

Full support 79

Firefox

Full support 1

IE

No support No

Opera

Full support 40

Safari

No support No

WebView Android

Full support 53

Chrome Android

Full support 53

Firefox Android

Full support 4

Opera Android

Full support 41

Safari iOS

No support No

Samsung Internet Android

Full support 6.0

auto Chrome

Full support 1

Edge

Full support 12

Firefox

Full support 1

IE

Full support 10

Opera

Full support 15

Safari

Full support 2

WebView Android

Full support ≤37

Chrome Android

Full support 18

Firefox Android

Full support 4

Opera Android

Full support 14

Safari iOS

Full support 3

Samsung Internet Android

Full support 1.0

contain Chrome

No support No

Edge No support 12 — 79

Alternate Name'

No support 12 — 79

Alternate Name'

Alternate Name' Uses the non-standard name: element

Firefox

No support No

IE Full support 10

Alternate Name'

Full support 10

Alternate Name'

Alternate Name' Uses the non-standard name: element

Opera

No support No

Safari

No support No

WebView Android

No support No

Chrome Android

No support No

Firefox Android

No support No

Opera Android

No support No

Safari iOS

No support No

Samsung Internet Android

No support No

none Chrome

Full support 1

Edge

Full support 12

Firefox Full support 21


Full support 21


No support 1 — 65

Prefixed'

Prefixed' Implemented with the vendor prefix: -moz-

IE

Full support 10

Opera

Full support 15

Safari

Full support 2

WebView Android

Full support ≤37

Chrome Android

Full support 18

Firefox Android Full support 21


Full support 21


No support 4 — 65

Prefixed'

Prefixed' Implemented with the vendor prefix: -moz-

Opera Android

Full support 14

Safari iOS

Full support 3

Samsung Internet Android

Full support 1.0

text Chrome

Full support 1

Edge

Full support 12

Firefox

Full support 1

IE

Full support 10

Opera

Full support 15

Safari Partial support 2

Notes'

Partial support 2

Notes'

Notes' Allows typing in the <html> container.

WebView Android

Full support ≤37

Chrome Android

Full support 18

Firefox Android

Full support 4

Opera Android

Full support 14

Safari iOS Partial support 3

Notes'

Partial support 3

Notes'

Notes' Allows typing in the <html> container.

Samsung Internet Android

Full support 1.0

Legend

Full support  
Full support
Partial support  
Partial support
No support  
No support
See implementation notes.'
See implementation notes.
User must explicitly enable this feature.'
User must explicitly enable this feature.
Uses a non-standard name.'
Uses a non-standard name.
Requires a vendor prefix or different name for use.'
Requires a vendor prefix or different name for use.


See also