Skip to main content
2 of 4
added 100 characters in body
Gaurav Aggarwal
  • 10.2k
  • 8
  • 42
  • 76

Suppose there are two div like this

HTML

<div class="first"> This is my first div </div> <div class="second"> This is my second div </div> 

Here we want to disable text selection of second div. Here is the css for that

CSS

.second { cursor: default; user-select: none; -webkit-user-select: none; /* Chrome/Safari/Opera */ -moz-user-select: none; /* Firefox */ -ms-user-select: none; /* IE/Edge */ -webkit-touch-callout: none; /* iOS Safari */ } 

Set cursor to default so that it will give a unselectable feel to user/

Prefix need to be use to support it in all browsers without prefix this may not work in all the answers.

Gaurav Aggarwal
  • 10.2k
  • 8
  • 42
  • 76