CSS user-select Property
Example
Prevent text selection of a <div> element:
div
{
-webkit-user-select: none; /* Safari 3.1+ */
-moz-user-select: none; /* Firefox 2+ */
-ms-user-select:
none; /* IE 10+ */
user-select: none; /* Standard
syntax */
}
Try it Yourself »
Definition and Usage
The user-select
property specifies whether the text of an element can be selected.
In web browsers, if you double-click on some text it will be selected/highlighted. This property can be used to prevent this.
Default value: | auto |
---|---|
Inherited: | no |
Animatable: | no. Read about animatable |
Version: | CSS3 |
JavaScript syntax: | object.style.userSelect="none" Try it |
Browser Support
The numbers in the table specify the first browser version that fully supports the property.
Numbers followed by -webkit- or -moz- specify the first version that worked with a prefix.
Property | |||||
---|---|---|---|---|---|
user-select | 54.0 6.0 -webkit- |
10.0 -ms- | 2.0 -moz- | 3.1 -webkit- | 41.0 15.0 -webkit- |
CSS Syntax
user-select: auto|none|text|all;
Property Values
Value | Description | Play it |
---|---|---|
auto | Default. Text can be selected if the browser allows it | Play it » |
none | Prevent text selection | Play it » |
text | The text can be selected by the user | Play it » |
all | Text selection is made with one click instead of a double-click | Play it » |
Related Pages
HTML DOM reference: userSelect property