How to disable text selection

Learn how to disable text selection in HTML using CSS.

This text can be selected.

This text cannot be selected.

disable text selection

You can use user-select property to disable text selection for elements.

In web browsers, if you double-click on text, it will be selected/highlighted. This property can be used to prevent this situation.

.prevent-select {
  -webkit-user-select: none; /* Safari */
  -ms-user-select: none; /* IE 10 and IE 11 */
  user-select: none; /* Standard syntax */
}

Try it yourself

Related pages

Reference manual:CSS user-select property