Naši dobrovolníci ještě tento článek do jazyka Čeština nepřeložili. Přidejte se a pomozte nám tuto práci dokončit!
Tento článek si můžete přečíst také v jazyce English (US).

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;

Note: This property correlates to the JavaScript Selection object.

Note: Many browsers still require a prefix to use this property. Check the compatibility table below.

Initial valueauto
Applies toall elements
Inheritedno
Mediavisual
Computed valueas specified
Animation typediscrete
Canonical orderthe unique non-ambiguous order defined by the formal grammar

Syntax

none
The text of the element and its sub-elements is not selectable. Note that the 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:

  • On the ::before and ::after pseudo elements, the computed value is none
  • If the element is an editable element, the computed value is contain
  • Otherwise, if the computed value of user-select on the parent of this element is all, the computed value is all
  • Otherwise, if the computed value of user-select on the parent of this element is none, the computed value is none
  • Otherwise, the computed value is text
text
The text can be selected by the user.
-moz-none
The text of the element and sub-elements will appear as if they cannot be selected. Note that the 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
In an HTML editor, if a double-click or context-click occurred in sub-elements, the highest ancestor with this value will be selected.
contain
element (IE-specific alias)
Enables selection to start within the element; however, the selection will be contained by the bounds of that element. Supported only in Internet Explorer.

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.

auto | text | none | contain | all

Example

HTML

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

CSS

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

Result

Specifications

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.

Browser compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidiOS SafariSamsung Internet
Basic support
Experimental
Chrome Full support 54
Full support 54
Full support 6
Prefixed
Prefixed Requires the vendor prefix: -webkit-
Edge Full support 12
Prefixed
Full support 12
Prefixed
Prefixed Requires the vendor prefix: -ms-
Full support 12
Prefixed
Prefixed Requires the vendor prefix: -webkit-
Firefox Full support Yes
Prefixed
Full support Yes
Prefixed
Prefixed Requires the vendor prefix: -moz-
Full support 49
Prefixed
Prefixed Requires the vendor prefix: -webkit-
Full support 44
Prefixed Disabled
Prefixed Requires 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 10Opera Full support 15
Prefixed
Full support 15
Prefixed
Prefixed Requires the vendor prefix: -webkit-
Safari Full support 3.1
Prefixed
Full support 3.1
Prefixed
Prefixed Requires the vendor prefix: -webkit-
WebView Android Full support 54
Full support 54
Full support Yes
Prefixed
Prefixed Requires the vendor prefix: -webkit-
Chrome Android Full support 54
Full support 54
Full support 18
Prefixed
Prefixed Requires the vendor prefix: -webkit-
Edge Mobile Full support 12
Prefixed
Full support 12
Prefixed
Prefixed Requires the vendor prefix: -ms-
Full support 12
Prefixed
Prefixed Requires the vendor prefix: -webkit-
Firefox Android Full support Yes
Prefixed
Full support Yes
Prefixed
Prefixed Requires the vendor prefix: -moz-
Full support 49
Prefixed
Prefixed Requires the vendor prefix: -webkit-
Full support 44
Prefixed Disabled
Prefixed Requires 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 Requires the vendor prefix: -webkit-
Safari iOS Full support 3.2
Prefixed
Full support 3.2
Prefixed
Prefixed Requires the vendor prefix: -webkit-
Samsung Internet Android Full support 6.0
Prefixed
Full support 6.0
Prefixed
Prefixed Requires the vendor prefix: -webkit-
auto
Experimental
Chrome Full support YesEdge Full support 12Firefox Full support YesIE Full support 10Opera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesEdge Mobile Full support 12Firefox Android Full support YesOpera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yes
all
Experimental
Chrome Full support YesEdge Full support 12Firefox Full support YesIE Full support 10Opera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesEdge Mobile Full support 12Firefox Android Full support YesOpera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yes
none
Experimental
Chrome Full support YesEdge Full support 12Firefox Full support 21
Full support 21
Full support Yes
Prefixed
Prefixed Requires the vendor prefix: -moz-
IE Full support 10Opera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesEdge Mobile Full support 12Firefox Android Full support 21
Full support 21
Full support Yes
Prefixed
Prefixed Requires the vendor prefix: -moz-
Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yes
text
Experimental
Chrome Full support YesEdge Full support 12Firefox Full support YesIE Full support 10Opera Full support YesSafari Partial support Partial
Notes
Partial support Partial
Notes
Notes Allows typing in the <html> container.
WebView Android Full support YesChrome Android Full support YesEdge Mobile Full support 12Firefox Android Full support YesOpera Android Full support YesSafari iOS Partial support Partial
Notes
Partial support Partial
Notes
Notes Allows typing in the <html> container.
Samsung Internet Android Full support Yes
contain
Experimental
Chrome No support NoEdge Full support 12
Full support 12
Full support 12
Alternate Name
Alternate Name Uses the non-standard name: element
Firefox No support NoIE Full support Yes
Full support Yes
Full support 10
Alternate Name
Alternate Name Uses the non-standard name: element
Opera No support NoSafari No support NoWebView Android No support NoChrome Android No support NoEdge Mobile Full support 12
Full support 12
Full support 12
Alternate Name
Alternate Name Uses the non-standard name: element
Firefox Android No support NoOpera Android No support NoSafari iOS No support NoSamsung Internet Android No support No

Legend

Full support  
Full support
Partial support  
Partial support
No support  
No support
Experimental. Expect behavior to change in the future.
Experimental. Expect behavior to change in the future.
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