Nahid Hossain

Nahid Hossain

Web Application & Software Developer

Prevent Selecting Text using CSS

To prevent/disable html text selection , you can use the following css :

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

For example:

 

<!-- By Nahid Hossain | <a href="http://www.akmnahid.com">www.akmnahid.com</a> -->
<! Doctype html>
<html>
    <head>
        <style type = "text / css">
             * .unselectable {
                 -moz-user-select: -moz-none;
                 -khtml-user-select: none;
                 -webkit-user-select: none;
                -ms-user-select: none;
                user-select: none;
            }
         </style>
    </head>
    <body>
        <div class = "unselectable">
             <p> This is unselectable text </p>
         </div>
    </body>
</html>

 

 

Leave A Comment

Your email address will not be published. Required fields are marked *