User Select
The user-select property controls whether the user can select text.
Basic Concepts
The behavior for user-select: auto is as follows:
- On the
::beforeand::afterpseudo elements, the used value isnone - If the element is an editable element (e.g.
<input>), the used value iscontain - Otherwise, if the
user-selectvalue of the parent isall, the used value isall - Otherwise, if the
user-selectvalue of the parent isnone, the used value isnone - Otherwise, the used value is
text
CSS Properties
user-select
Controls whether the user can select text.
auto— use default behavior (see above)none— the text of the element and its children is not selectabletext— the text can be selectedall— when selecting the text, select ALL of the element's textcontain— the text can be selected, but the selection will be contained by the bounds of that element
<div id="user-select-example">
Select all text automatically!
</div>#user-select-example {
user-select: all;
} | LIVE PREVIEW
Select all text automatically!
References
- user-select (MDN) — https://developer.mozilla.org/en-US/docs/Web/CSS/user-select