How to Disable Text Selection using CSS

Posted by Lasantha Bandara on August 12th, 2015 File Under : css0 Comment

Do you need to disable text selection / text highlighting of your website without using any JavaScript code? If the answer is yes, add this CSS code into your website to prevent users selecting text of your website or blog.

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

If you are using blogger, add it just before ]]></b:skin>.

To understand how it works, try to select below text.

Hi, I am an unselectable text. If you are not sure, try to select me.

File Under : css

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.