Neil Neil - 4 months ago 9
CSS Question

CSS disable text selection

Currently, I have put this in the body tag to disable text selections:

body {
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}


However, my
input
and
textarea
boxes are now unselectable. How can I only make these input elements selectable and the rest unselectable?

Answer

Don't apply these properties to the whole body. Move them to a class and apply that class to the elements you want to disable select:

.disable-select {
  -webkit-user-select: none;  
  -moz-user-select: none;    
  -ms-user-select: none;      
  user-select: none;
}