files/en-us/web/css/reference/properties/user-select/index.md
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 {{Glossary("Chrome", "chrome")}}), except in textboxes.
{{InteractiveExample("CSS Demo: user-select")}}
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;
}
/* 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-selectis not an inherited property, though the initialautovalue 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.
none
auto
auto is determined as follows:
::before and ::after pseudo elements, the used value is noneuser-select on the parent of this element is none, the used value is noneuser-select on the parent of this element is all, the used value is alltexttext
all
[!NOTE] The CSS basic user interface module defines a
containvalue for theuser-selectproperty 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.
{{CSSInfo}}
{{csssyntax}}
<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>
.unselectable {
-webkit-user-select: none; /* Safari */
user-select: none;
}
.all {
-webkit-user-select: all;
user-select: all;
}
{{EmbedLiveSample("Examples")}}
{{Specifications}}
{{Compat}}