15

Possible Duplicate:
css rule to disable text selection highlighting
Prevent text selection after double click

Even though my events are properly prenting default actions, clicking in text and then Shift-clicking in other text is causing a selection. This is undesirable behaviour in this case, since I'm using Shift-click to multi-select these elements.

Is there something I need to do to specifically disable selection here?

EDIT: Found solution to my own problem here. Sorry for wasting people's time.

Community
  • 1
  • 1
Niet the Dark Absol
  • 301,028
  • 70
  • 427
  • 540
  • and a Javascript/jQuery solution: [how to disable text selection using jquery](http://stackoverflow.com/questions/2700000/how-to-disable-text-selection-using-jquery) – Robert Koritnik Oct 10 '12 at 16:19
  • I can't believe this question is marked as answered when none of the answers provide what is originally asked. The question is how to prevent selection on SHIFT+Click, not preventing text from being selected at all. Well, it's the Internet... – andreak Feb 16 '18 at 16:41
  • @andreak No, that's an [XY problem](https://meta.stackexchange.com/questions/66377/what-is-the-xy-problem). – Niet the Dark Absol Feb 16 '18 at 16:47

1 Answers1

17

Add this CSS to the section where you want to prevent text-selection:

-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-o-user-select: none;
user-select: none;

Earlier versions of IE require you to add the attribute onselectstart, something like this:

<div onselectstart="return false">
Porco
  • 3,948
  • 2
  • 20
  • 25