CSS user-select Property

Beginner
5 min read
Updated: Oct 2026
3 examples
Live preview

Definition and Usage

The user-select property controls whether the user can select text in an element with the mouse, touch, or keyboard.

The initial value is auto. Common values are none (block selection), text (allow selection), and all (select the whole element atomically). It does not affect browser chrome, except inside textboxes. Include -webkit-user-select for Safari.

Limited availability Not Baseline

MDN marks user-select as Limited availability. Core keywords still work widely when you also set -webkit-user-select. The spec value contain is not supported in browsers.

CSS Syntax

syntax.css
user-select: auto | none | text | all | initial | inherit;

Examples: none; · text; · all; · with prefix: -webkit-user-select: none;

Property Values

ValueDescriptionTry it
autoDefault. Usually acts like text (or follows parent none/all)Try it
noneText cannot be selectedTry it
textNormal text selection allowedTry it
allSelecting any part selects the whole elementTry it
containSpec-only today — not supported in browsersTry it
initial / inheritReset to auto, or take the parent valueTry it

How to Use user-select

Pick a keyword, add the WebKit prefix for Safari, then try selecting the text.

  1. Choose none, text, all, or leave auto.
  2. Set both -webkit-user-select and user-select.
  3. Apply it to controls (icons, buttons) or copyable blocks as needed.
  4. Do not block selection on body text users may need to copy.
PieceRequired?Role
KeywordYesControls selection behavior
-webkit-user-selectRecommendedSafari / older WebKit
ScopeImportantLimit none to UI chrome, not article copy
Keyboard / a11yConsiderBlocking selection can hurt users who copy text

Live Preview

Change the value, then try selecting the sample text with your mouse or finger.

Try dragging across the sample. With all, a partial drag often selects the whole block.

Sample

Select this sentence to test user-select. CodeToFun demo text.

user-select: none

CSS Examples

Each snippet focuses on user-select. Include the WebKit prefix for Safari. Use Try It Yourself for a live editor.

Example 1 — Disable Selection

Stop accidental highlighting on a control label.

CSS
<style>
  .btn {
    -webkit-user-select: none;
    user-select: none;
  }
</style>

<button type="button" class="btn">Click me</button>
Try It Yourself

How It Works

  1. Set none. The control’s text is not selectable.
  2. Add -webkit-. Safari needs the prefixed property.
  3. Better UX on clicks. Fast double-clicks do not highlight the label.
  4. Scope carefully. Keep readable article text selectable.

Example 2 — Allow Text Selection

Make a block explicitly selectable.

CSS
<style>
  .copy {
    -webkit-user-select: text;
    user-select: text;
  }
</style>

<p class="copy">You can select and copy this paragraph.</p>
Try It Yourself

How It Works

  1. Set text. Normal drag selection works inside the element.
  2. Overrides a parent none. Useful when a toolbar is unselectable but a child quote must copy.
  3. Prefix again. Keep -webkit-user-select: text for Safari.
  4. Default-like. Often matches what auto resolves to on plain content.

Example 3 — Select the Whole Block

Any selection inside the element expands to the entire element.

CSS
<style>
  .code {
    -webkit-user-select: all;
    user-select: all;
  }
</style>

<code class="code">npm install codetofun</code>
Try It Yourself

How It Works

  1. Set all. Selection is atomic for this element.
  2. Partial drag expands. Starting inside still selects the whole node and descendants.
  3. Handy for copy-paste. Short commands and IDs are easier to grab in one gesture.
  4. Not contain. Do not rely on contain — browsers do not support it yet.

Edge Cases & Pitfalls

If selection still works (or never works), check these first.

safari

Need -webkit-user-select

Safari historically requires the prefixed property. Set both -webkit-user-select and user-select.

a11y

Do not lock readable content

Blocking selection on paragraphs, docs, or error messages hurts users who copy text. Prefer none only on chrome/controls.

inherit

Spec vs engines

Per the spec, user-select is not inherited, but auto often behaves as if it were. Chromium/WebKit may treat it as inherited — set children explicitly when unsure.

contain

contain is unsupported

The CSS UI module defines contain, but no major browser ships it. Do not use it in production.

api

none is not a security boundary

Script can still read text from the DOM. Selection APIs may still include nodes marked none. Do not treat this as copy protection.

Browser Support

user-select is a browser CSS property for text selection. Node.js, Deno, and Bun do not apply it.

✓ Limited availability

user-select

none, text, auto, and all are practical across modern browsers when you include -webkit-user-select for Safari. MDN marks the feature Limited availability. contain has no browser support.

90% Practical support
Google Chrome 54+
Full support
Mozilla Firefox 69+
Full support
Apple Safari 3.1+*
Prefixed
Microsoft Edge 79+
Full support
Opera 41+
Full support
Samsung Internet 6.2+
Full support
Internet Explorer 10+*
Partial / prefixed
user-select Use with -webkit-

Bottom line: *Prefer -webkit-user-select alongside user-select. Safe for UI controls; avoid locking body copy. It is not a runtime API.

Key Takeaways

  • Role: allow or block user text selection in an element.
  • Initial value: auto — usually behaves like selectable text.
  • none vs all: block selection vs grab the whole element at once.
  • Prefix + caution: use -webkit-; never treat none as copy protection.

One line: use none on UI chrome, text/all when users should copy, and always add the WebKit prefix.

Frequently Asked Questions

It controls whether the user can select text in an element with the mouse, touch, or keyboard. It does not affect browser chrome, except in textboxes.
The initial value is auto. Its used value usually resolves to text, or follows a parent’s none/all in some cases.
Set user-select: none (and -webkit-user-select: none for Safari) on the button or control so clicks and drags do not highlight label text.
none makes the element’s text unselectable. text allows normal selection inside the element.
Per the spec it is not inherited, but auto often behaves as if it were. Chromium/WebKit historically treat it as inherited; prefer explicit values on children when needed.
none, text, auto, and all are widely usable with -webkit-user-select for Safari. MDN marks the property Limited availability. contain is not supported. It is a browser CSS property, not a Node.js feature.

Next: vertical-align

Learn how vertical-align positions inline and table-cell content.

vertical-align tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful