CSS userselect Property (original) (raw)
CSS user-select Property
Last Updated : 23 Sep, 2024
The **user-select property in CSS is used to control whether users can highlight and select text on a webpage. You can use it to allow or prevent users from selecting certain text. For example, if you want to stop users from copying specific content, you can disable text selection.
On the other hand, you can also make sure that certain text is always selectable. This property is useful for controlling how users interact with text on your website.
**Note: The double-click on some text will be selected/highlighted but this property can be used to prevent this.
Syntax
The **user-select property uses the following syntax:
**user-select: auto | none | text | all;
**Default Value: auto
Property Values
| **Value | **Description |
|---|---|
| **auto | Default value. The user can select the text normally. |
| **none | Prevents text selection, meaning the user cannot select any text. |
| **text | Allows the user to select the text. |
| **all | Selects the entire text with a single mouse click, instead of requiring a double-click. |
CSS user-select Property - Examples
Below are some examples demonstrating how the user-select property works.
Example 1: Using user-select: auto
In this example, the user-select: auto property allows the text inside the div element to be selectable as per the default browser behavior.
html `
user-select property