1

Is it possible for a user to select text on a web page using a mobile browser? With the CSS property "user-select: all" the whole text will be highlighted, but I also want to allow selecting specific words without assigning the property everywhere. See the code example below in order to see what I tried so far.

.all {
  -moz-user-select: all;
  -webkit-user-select: all;
  -ms-user-select: all;
  user-select: all;
}
<p>You should be able to select this text.</p>
<p class="all">Clicking once will select all of this text.</p>

3
  • That one works only when the user selects text using mouse! If you wanted to highlight the text! you need to use color property in css Commented Oct 21, 2021 at 13:54
  • "I also want to allow highlighting specific words without assigning the property everywhere" By this, do you just mean the default selection capabilities, as in your first <p> tag without the "all" class? Commented Oct 21, 2021 at 15:21
  • @GetOffMyLawn Yes I do mean that. Commented Oct 21, 2021 at 15:33

1 Answer 1

1

Is it possible for a user to highlight text on a web page using a mobile browser?

Yes, if you navigate to the Mozilla page for user-select on your mobile device, you can see it in action. There's also a list of compatibility across browsers: https://developer.mozilla.org/en-US/docs/Web/CSS/user-select

Alternatively, I tried running this in Firefox' responsive design mode using the touch simulation featur and "touching" the bottom text (with the "all" class applied) produces the same effect as clicking it on the desktop.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.