Open In App

What is the use of the user-select Property?

Last Updated : 02 Feb, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

The user-select property in CSS is used to control the user’s ability to select text. It allows you to define whether text within an element can be selected, preventing or allowing users to highlight and copy content.

Note: The user-select property can take values such as none, auto, text, and all.

/* Disabling text selection within an element */
.unselectable {
user-select: none;
}

/* Allowing text selection within an element */
.selectable {
user-select: text;
}

Features:

The user-select properties are as:

  • none: Prevents text selection within the element.
  • auto: Allows the browser to determine whether text can be selected (default behavior).
  • text: Enables text selection within the element.
  • all: Allows users to select everything, including images and other non-text content.


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads