No Login Data Private Local Save

user‑select CSS Playground - Online Text Selection Control

8
0
0
0

CSS user-select Playground

Interactively explore and test the CSS user-select property. Control how users select text — disable selection, enable one-click select-all, and more.

Choose Value
Current mode: auto — Browser Default
Live Preview — try selecting the text below
Click and drag to try selecting this text. Try switching between different user-select values above to see how the selection behavior changes. The quick brown fox jumps over the lazy dog.
Click and drag across the text above to test selection behavior.
Side-by-Side Comparison — try selecting text in each card
🟦
auto
The browser decides selection behavior. This is the default — text is selectable like normal content.
🟪
text
Text selection is explicitly enabled. Useful for overriding a parent's user-select: none.
🟧
none
Text cannot be selected! Try it — your cursor won't change to a text selector here. Great for buttons & UI.
🟩
all
Click or start selecting — the entire text block is selected at once. Perfect for code snippets & copyable content.
Generated CSS
/* Apply to target element */
-webkit-user-select: auto;
-moz-user-select: auto;
-ms-user-select: auto;
user-select: auto;

Always include vendor prefixes for maximum cross-browser compatibility.

Real-World Use Cases
Prevent Button Text Selection

Stop users from accidentally selecting button labels during rapid clicking.

Click Me — Can't Select This
One-Click Code Snippets

Make code blocks fully selectable with a single click for easy copying.

npm install tailwindcss
Override Parent none

Allow selection in specific child elements even when the parent disables it.

🔒 Unselectable area
🔓 But this is selectable!
Browser Compatibility
Browser auto text none all Prefix Needed
Chrome 54+ -webkit-
Firefox 69+ -moz-
Safari 16+ -webkit-
Edge 79+ -ms- (legacy)
iOS Safari 16+ -webkit-
Android Chrome -webkit-

Data sourced from MDN & Can I Use. Always test in your target browsers.

Frequently Asked Questions — SEO-friendly knowledge base

The user-select CSS property controls whether and how users can select text within an element. It determines if text can be highlighted, copied, or interacted with via cursor selection. This property is especially useful for improving UX on interactive elements like buttons, drag-and-drop interfaces, code snippets, and any scenario where accidental text selection could degrade the experience. Supported values include auto (browser default), text (selection enabled), none (selection disabled), and all (one-click select-all).

Use user-select: none; along with browser vendor prefixes for full coverage. The complete CSS rule is:

-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;


This prevents users from highlighting text within the target element. It's commonly used on buttons, navigation menus, icons, and drag handles to avoid accidental text selection during interaction. Note that this does not prevent copying via other means (like View Source) — it only affects cursor-based selection.

user-select: all makes the entire text content of an element selectable in a single action. When a user starts selecting anywhere inside the element, the browser automatically expands the selection to encompass all text within that element. This is ideal for:

  • Code snippets & commands — users can copy with one click
  • API keys, tokens, or URLs — reduce friction when copying
  • Error messages — let users quickly copy error codes
  • Short quotes or references — convenient one-click copying
Note: In most modern browsers, a double-click or click-drag within the element triggers the full selection automatically.

These are fundamentally different properties:

user-select: none — Only prevents text selection. The element still receives clicks, hover states, focus, and all other pointer interactions. It's purely about text highlighting.

pointer-events: none — Makes the element completely transparent to mouse/touch events. Clicks pass through to elements behind it. The element won't receive hover, focus, or any interaction. Text inside may still be selectable if the selection starts from a neighboring element.

Use user-select: none for buttons and UI elements. Use pointer-events: none for decorative overlays or when you need clicks to pass through.

When a parent element has user-select: none, all child elements inherit this behavior. To re-enable selection for specific children, apply user-select: text (with prefixes) to those child elements:

.unselectable-card { user-select: none; }
.unselectable-card .copyable-content { user-select: text; }


This pattern is useful for card UIs where the card itself shouldn't be selectable, but certain content areas (like code blocks or addresses) should be copyable.

Yes, user-select works on mobile browsers including iOS Safari and Android Chrome. However, mobile behavior has some nuances:

  • Touch vs. long-press: On mobile, text selection is typically triggered by a long-press gesture. user-select: none prevents the text selection popup from appearing.
  • iOS Safari: Fully supports all values with the -webkit- prefix since iOS 16.
  • Android Chrome: Supports all values, also requiring -webkit- prefix.
  • all value on mobile: A tap or long-press within the element should select all text, though behavior may vary slightly across browsers.
Always test on real devices to ensure the expected behavior.

For maximum browser compatibility, include all three vendor prefixes before the standard property:

-webkit-user-select: <value>; /* Chrome, Safari, Opera, Edge */
-moz-user-select: <value>; /* Firefox */
-ms-user-select: <value>; /* Internet Explorer / legacy Edge */
user-select: <value>; /* Standard syntax */


As of 2024, the -ms- prefix is largely unnecessary for modern browsers, but it's still recommended for legacy Edge (versions 12-18) and Internet Explorer support. If you don't need IE/legacy Edge support, you can safely omit the -ms- prefix.

user-select: none only prevents visual text selection via cursor/touch. It does not prevent determined users from copying content through other methods:

  • Using browser DevTools to inspect and copy text
  • Viewing the page source (Ctrl+U / Cmd+U)
  • Disabling CSS in the browser
  • Using JavaScript to extract text content
  • Taking a screenshot and using OCR
If you need stronger protection, consider serving content as images, using canvas rendering, or implementing DRM — though these approaches have significant UX trade-offs and are rarely recommended for general web content.

user-select: contain was part of an early draft of the CSS UI Level 4 specification. The idea was that selection would be confined to the element's boundary — you couldn't accidentally extend selection into neighboring elements. However, this value was removed from the specification and is not supported by any modern browser. The current valid values are auto, text, none, and all. If you encounter code using contain, it's outdated and should be replaced with one of the standard values.

No, user-select is a discrete property — it has distinct, non-interpolable values. You cannot smoothly transition or animate between none and text because there are no intermediate states. If you need a visual transition effect (e.g., fading in selectable text), consider animating other properties like opacity, color, or using CSS transitions on a wrapper element while toggling user-select instantly via JavaScript at the appropriate moment.