Home html How can I disable the selection of text?

How can I disable the selection of text? [duplicate]

Author

Date

Category

How can I prevent the selection of text in a specific element?


Answer 1, authority 100%

Cross-browser solution:

. unselectable {
 -webkit-touch-callout: none; / * iOS Safari * /
 -webkit-user-select: none; / * Chrome / Safari / Opera * /
 -khtml-user-select: none; / * Konqueror * /
 -moz-user-select: none; / * Firefox * /
 -ms-user-select: none; / * Internet Explorer / Edge * /
 user-select: none; / * Non-prefixed version, currently
                 not supported by any browser * /
} 
& lt; p & gt;
 Selectable text.
& lt; / p & gt;
& lt; p class = "unselectable" & gt;
 Unselectable text.
& lt; / p & gt; 

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions