MDN may have intermittent access issues April 18 13:00 - April 19 01:00 UTC. See whistlepig.mozilla.org for all notifications.

mozilla
Your Search Results

    user-select

    Non-standard
    This feature is non-standard and is not on a standards track. Do not use it on production sites facing the Web: it will not work for every user. There may also be large incompatibilities between implementations and the behavior may change in the future.

     

    Summary

    Controls the actual Selection operation. This doesn't have any effect on content loaded as chrome, except in textboxes. A similar property 'user-focus' was proposed in early drafts of a predecessor of css3-ui but was rejected by the working group.

    Note: Check the compatibility table for the proper prefixes to use in various browsers. Also note that the syntax and behavior of an experimental technology is subject to change in future versions of browsers.

    Syntax

    -moz-user-select: none;
    -moz-user-select: text;
    -moz-user-select: all;
    
    -webkit-user-select: none;
    -webkit-user-select: text;
    -webkit-user-select: all;
    
    -ms-user-select: none;
    -ms-user-select: text;
    -ms-user-select: all;
    -ms-user-select: element;
    
    none
    The text of the element and sub-elements will not be able to be selected. Selection can contain these elements. Starting with Firefox 21 none behaves like -moz-none, so selection can be re-enabled on sub-elements using -moz-user-select:text.
    text
    The text can be selected by the user.
    -moz-none
    The text of the element and sub-elements will appear as if they cannot be selected. Selection can contain these elements. Selection can be re-enabled on sub-elements using -moz-user-select:text. Starting with Firefox 21 none behaves like -moz-none.
    all
    In an HTML editor, if a double-click or context-click occurred in sub-elements, the highest ancestor with this value will be selected.
    element
    Supported only in Internet Explorer. Enables selection to start within the element; however, the selection will be contained by the bounds of that element.
    Note: user-select is not currently part of any W3C CSS specification. As such, there are minor differences between the browser implementations. Be sure to test your application across browsers.

    Note: One of the differences between browser implementations is inheritance. In Firefox, -moz-user-select is not inherited by absolutely positioned elements, but in Safari and Chrome, -webkit-user-select is inherited by those elements.

    Formal syntax

    none | text | all | element

    Examples

    .unselectable {
      -moz-user-select: none;
      -webkit-user-select: none;
      -ms-user-select: none;
    }
    
    <body>
      <p class="unselectable">The user is not able to select this text in Firefox, Chrome, Safari and IE.</p>
    </body>
    

    Browser compatibility

    Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
    Basic support 6.0-webkit- (Yes)-moz- 10-ms- 15.0-webkit- 3.1-webkit-
    element Not supported Not supported (Yes)   Not supported
    Feature Android Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
    Basic support 2.1 ? 10(Yes)-ms-
    11-webkit-
    Not supported 3.2(Yes)

    See also

    Hide Sidebar