user-select
        
        
          Limited availability
        
        
        
          
                
              
                
              
                
              
        
        
      
      This feature is not Baseline because it does not work in some of the most widely-used browsers.
The user-select CSS property controls whether the user can select text. This doesn't have any effect on content loaded as part of a browser's user interface (its chrome), except in textboxes.
Try it
user-select: none;
user-select: text;
user-select: all;
<section id="default-example">
  <p id="example-element">Try to select this text</p>
</section>
#example-element {
  font-size: 1.5rem;
}
Syntax
/* Keyword values */
user-select: none;
user-select: auto;
user-select: text;
user-select: all;
/* Global values */
user-select: inherit;
user-select: initial;
user-select: revert;
user-select: revert-layer;
user-select: unset;
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 has chosen to fix the issues to make the final behavior meet the specifications.
Values
- none
- 
The text of the element and its sub-elements is not selectable. Note that the Selectionobject can contain these elements.
- auto
- 
The used value of autois determined as follows:- On the ::beforeand::afterpseudo elements, the used value isnone
- If the used value of user-selecton the parent of this element isnone, the used value isnone
- Otherwise, if the used value of user-selecton the parent of this element isall, the used value isall
- Otherwise, the used value is text
 
- On the 
- 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. 
Note:
The CSS basic user interface module defines a contain value for the user-select property to enable selection to start within the element to be contained by the bounds of that element, however, this is not supported in any browsers.
Formal definition
| Initial value | auto | 
|---|---|
| Applies to | all elements | 
| Inherited | no | 
| Computed value | as specified | 
| Animation type | discrete | 
Formal syntax
user-select =
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 {
  -webkit-user-select: none; /* Safari */
  user-select: none;
}
.all {
  -webkit-user-select: all;
  user-select: all;
}
Result
Specifications
| Specification | 
|---|
| CSS Basic User Interface Module Level 4> # content-selection> | 
Browser compatibility
Loading…
See also
- ::selectionpseudo-element
- The JavaScript Selectionobject