user-select CSS property controls whether the user can select text. This doesn't have any effect on content loaded as chrome , except in textboxes.

/* Keyword values */
user-select: none;
user-select: auto;
user-select: text;
user-select: contain;
user-select: all;
/* Global values */
user-select: inherit;
user-select: initial;
user-select: unset;
/* Mozilla-specific values */
-moz-user-select: none;
-moz-user-select: text;
-moz-user-select: all;
/* WebKit-specific values */
-webkit-user-select: none;
-webkit-user-select: text;
-webkit-user-select: all; /* Doesn't work in Safari; use only
                             "none" or "text", or else it will
                             allow typing in the <html> container */
/* Microsoft-specific values */
-ms-user-select: none;
-ms-user-select: text;
-ms-user-select: element;
					

注意 : user-select is not an inherited property, though the initial auto value 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 chooses to fix the issues , make the final behavior meets the specifications.

句法

none
The text of the element and its sub-elements is not selectable. Note that the Selection object can contain these elements.
auto

The used value of auto is determined as follows:

  • On the ::before and ::after pseudo elements, the used value is none
  • If the element is an editable element, the used value is contain
  • Otherwise, if the used value of user-select on the parent of this element is all , the used value is all
  • Otherwise, if the used value of user-select on the parent of this element is none , the used value is none
  • Otherwise, the used value is text
text

The text can be selected by the user.

all

The content of the element shall be selected atomically: If a selection would contain part of the element, then the selection must contain the entire element including all its descendants.  If a double-click or context-click occurred in sub-elements, the highest ancestor with this value will be selected.

contain

Enables selection to start within the element; however, the selection will be contained by the bounds of that element.

element (IE-specific alias)
如同 contain . Supported only in Internet Explorer.

注意: CSS UI 4 renames user-select: element to contain .

形式定义

初始值 auto
适用于 所有元素
继承 no
计算值 如指定
动画类型 discrete

形式句法

auto | text | none | contain | all
					

范例

HTML

<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>
					

CSS

.unselectable {
  -moz-user-select: none;
  -webkit-user-select: none;
  -ms-user-select: none;
  user-select: none;
}
.all {
  -moz-user-select: all;
  -webkit-user-select: all;
  -ms-user-select: all;
  user-select: all;
}
					

结果

规范

规范 状态 注释
CSS Basic User Interface Module Level 4
The definition of 'user-select' in that specification.
工作草案 Initial definition. Also defines -webkit-user-select as a deprecated alias of user-select .

浏览器兼容性

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
user-select Chrome 完整支持 54 Edge 完整支持 12 Prefixed
完整支持 12 Prefixed
Prefixed Implemented with the vendor prefix: -ms-
完整支持 Prefixed
Prefixed Implemented with the vendor prefix: -webkit-
Firefox 完整支持 69
完整支持 69
Prefixed Implemented with the vendor prefix: -webkit-
完整支持 1 Prefixed
Prefixed Implemented with the vendor prefix: -moz-
preference (needs to be set to ). To change preferences in Firefox, visit about:config.
IE 完整支持 10 Prefixed
完整支持 10 Prefixed
Prefixed Implemented with the vendor prefix: -ms-
Opera 完整支持 15 Prefixed
完整支持 Prefixed
Prefixed Implemented with the vendor prefix: -webkit-
Safari 完整支持 3 Prefixed
完整支持 Prefixed
Prefixed Implemented with the vendor prefix: -webkit-
不支持 2 — 3 Prefixed
Prefixed Implemented with the vendor prefix: -khtml-
WebView Android 完整支持 54 Chrome Android 完整支持 54 Firefox Android 完整支持 49 Prefixed
完整支持 Prefixed
Prefixed Implemented with the vendor prefix: -webkit-
完整支持 4 Prefixed
Prefixed Implemented with the vendor prefix: -moz-
preference (needs to be set to ). To change preferences in Firefox, visit about:config.
Opera Android 完整支持 14 Prefixed
完整支持 Prefixed
Prefixed Implemented with the vendor prefix: -webkit-
Safari iOS 完整支持 3 Prefixed
完整支持 Prefixed
Prefixed Implemented with the vendor prefix: -webkit-
Samsung Internet Android 完整支持 6.0
all Chrome 完整支持 53 Edge 完整支持 79 Firefox 完整支持 1 IE 不支持 No Opera 完整支持 40 Safari 不支持 No WebView Android 完整支持 53 Chrome Android 完整支持 53 Firefox Android 完整支持 4 Opera Android 完整支持 41 Safari iOS 不支持 No Samsung Internet Android 完整支持 6.0
auto Chrome 完整支持 1 Edge 完整支持 12 Firefox 完整支持 1 IE 完整支持 10 Opera 完整支持 15 Safari 完整支持 2 WebView Android 完整支持 ≤37 Chrome Android 完整支持 18 Firefox Android 完整支持 4 Opera Android 完整支持 14 Safari iOS 完整支持 3 Samsung Internet Android 完整支持 1.0
contain Chrome 不支持 No Edge 不支持 12 — 79 Alternate Name
不支持 12 — 79 Alternate Name
Alternate Name Uses the non-standard name: element
Firefox 不支持 No IE 完整支持 10 Alternate Name
完整支持 10 Alternate Name
Alternate Name Uses the non-standard name: element
Opera 不支持 No Safari 不支持 No WebView Android 不支持 No Chrome Android 不支持 No Firefox Android 不支持 No Opera Android 不支持 No Safari iOS 不支持 No Samsung Internet Android 不支持 No
none Chrome 完整支持 1 Edge 完整支持 12 Firefox 完整支持 21
完整支持 21
不支持 1 — 65 Prefixed
Prefixed Implemented with the vendor prefix: -moz-
IE 完整支持 10 Opera 完整支持 15 Safari 完整支持 2 WebView Android 完整支持 ≤37 Chrome Android 完整支持 18 Firefox Android 完整支持 21
完整支持 21
不支持 4 — 65 Prefixed
Prefixed Implemented with the vendor prefix: -moz-
Opera Android 完整支持 14 Safari iOS 完整支持 3 Samsung Internet Android 完整支持 1.0
text Chrome 完整支持 1 Edge 完整支持 12 Firefox 完整支持 1 IE 完整支持 10 Opera 完整支持 15 Safari 部分支持 2 注意事项
部分支持 2 注意事项
注意事项 Allows typing in the <html> container.
WebView Android 完整支持 ≤37 Chrome Android 完整支持 18 Firefox Android 完整支持 4 Opera Android 完整支持 14 Safari iOS 部分支持 3 注意事项
部分支持 3 注意事项
注意事项 Allows typing in the <html> container.
Samsung Internet Android 完整支持 1.0

图例

完整支持

完整支持

部分支持

部分支持

不支持

不支持

见实现注意事项。

见实现注意事项。

用户必须明确启用此特征。

用户必须明确启用此特征。

使用非标名称。

使用非标名称。

要求使用供应商前缀或不同名称。

要求使用供应商前缀或不同名称。

另请参阅

元数据

  • 最后修改:
  1. CSS
  2. CSS 参考
  3. CSS Basic User Interface
  4. 指南
    1. Using URL values for the cursor property
  5. 特性
    1. appearance (-moz-appearance, -webkit-appearance)
    2. aspect-ratio
    3. box-sizing
    4. caret-color
    5. cursor
    6. ime-mode
    7. outline
    8. outline-color
    9. outline-offset
    10. outline-style
    11. outline-width
    12. resize
    13. text-overflow
    14. user-select

Copyright  © 2014-2026 乐数软件    

工业和信息化部: 粤ICP备14079481号-1