Skip to content

Add support for the user-select property #47896

Open

Description

@SimonSapin

Spec: https://drafts.csswg.org/css-ui-4/#propdef-user-select

  • Applying to ::before and ::after to make them selectable: spec says “at risk”
  • user-select: auto has ad-hoc inheritance: the used value depends on the used value of the parent, even though the property is not inherited
  • user-select: text: default behavior
  • user-select: none:
    • Selection that would start here: input event inhibited
    • Selection that would end here: it ends instead at the element boundary (which one?)
    • Selection fully containing this: element excluded
      • From selection painting
      • From copy to clipboard (not a normative requirement but “encouraged”)
      • Maybe from document.getSelection() stringifier?
      • Descendants with a different user-select are included again
  • user-select: contain: specified but only implemented in IE11?
  • user-select: all: element entirely selected or not at all
  • Incomplete UA stylesheet: button, meter, progress, select { user-select: none; }
    • Also needs button-like <input>: is there more to it than this? input[type=button], input[type=file], input[type=image], input[type=reset], input[type=submit] { user-select: none; }

PRs:

Activity

  1. Psychpsyo commented on Sep 8, 2026

    @Psychpsyo
    Contributor

    The document selection stringifier also interacts with the default quotes on the <q> element in a weird way, although only in Firefox:
    w3c/csswg-drafts#12565
    TL;DR: Despite those being unselectable ::before and ::after pseudos from the UA stylesheet, Firefox does insert quotation marks into the string for them.

    Although I highly doubt it's necessary for Servo to care about that at current time and there is no spec for it.

  2. Psychpsyo commented on Sep 8, 2026

    @Psychpsyo
    Contributor

    Oh, and here's a manual test file I made for myself back when implementing this in Ladybird:

    <!DOCTYPE html>
    <style>
      #containerland span {
        border: 2px solid black;
        margin: .5em;
        display: inline-block;
      }
    </style>
    
    An example of <span style="user-select: text;">user-select:<span> </span>text</span> is this.<br>
    An example of <span style="user-select: all;">user-select:<span> </span>all</span> is this.<br>
    An example of <span style="user-select: none;">user-select:<span> </span>none</span> is this.<br>
    An example of <span style="user-select: contain;">user-select:<span> </span>contain</span> is this.
    
    <h1>Containerland:</h1>
    <div id="containerland">
      start <span>foo <span>bar <span style="user-select: contain; border-color: red;">baz <span>blah</span></span></span> <span>bang <span style="user-select: contain; border-color: red;">boom</span></span> hey</span> end
    </div>
  3. SimonSapin commented on Sep 8, 2026

    @SimonSapin
    MemberAuthor

    CSS UI spec says “the parent of this element”, “if this element has descendants on which”, “outside of this element”, etc. How does this interact with Shadow DOM? Gecko determines the used value based on the nsIFrame parent

  4. added
    A-content/css
    A-content/dom
    on Nov 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-content/cssA-content/dom

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions