Guide to CSS user-select for Beginners
·
1 min read

Table of contents
What is it?
The CSS user-select
property allows you to control the ability of users to select text on a webpage. This can be useful for improving user experience by enabling or disabling text selection as needed.
Syntax
element {
user-select: value;
}
Values
all
- The
all
value allows a user to select a block of text with just one click.
auto
- The
auto
value is the default behavior of the browser. It allows users to select text as they normally would depending on the browser.
none
- The
none
value disables or prevents text selection.
text
- The
text
value allows only text selection, ignoring other elements like images.
Example
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CSS user-select Example</title>
<style>
.select-all {
user-select: all;
}
.select-none {
user-select: none;
}
.select-text {
user-select: text;
}
</style>
</head>
<body>
<div class="select-all">Click me to select all text in this block.</div>
<div class="select-none">You cannot select this text.</div>
<div class="select-text">You can only select the text in this block, not any images.</div>
</body>
</html>
You can also view a live example on CodeSandbox: CSS user-select Example