disable copying text

Prevent People from Copying Your Text

Last modified: January 13, 2020


Let me start out by saying that there is no 100% way to prevent people from copying text from your site. Though there are 2 ways that make it just a bit harder for non savvy people from copying you.


Show More

* This button will show the rest of the post and open up an offer from a vendor

1. Disable Text Selection

Disabling text selection is a great way to discourage a user from trying to copy your content. It just makes it that much harder. This is how you do it.

  1. Add a nocopy class to your site’s <head>:
    • Go to your functions.phpfile and paste the following code at the end of it:
      add_filter( 'body_class', function( $classes ) {
          return array_merge( $classes, array( 'nocopy' ) );
      } );

      This code will add a class named nocopyto your site’s <head> section.

  2. Add rules in your style.css file that will disable text selection:
    • .nocopy {
       -webkit-touch-callout: none; 
       -webkit-user-select: none; 
       -khtml-user-select: none; 
       -moz-user-select: none; 
       -ms-user-select: none; 
       user-select: none; 


Once you save the CSS file, head over to any page on your site and check it out! You can’t select any part of text which will make it hard for people to start copying your content.

2. Disable Right Click

Disabling right clicking is another method which will definitely discourage anyone from trying to steal your content. All you need to do is head over to your header.php file and look for the opening <html> tag. Add this to it: oncontextmenu="return false"so your tag should look something like this:

<html <?php language_attributes(); ?> oncontextmenu="return false">


That’s basically it!

Now, the odds of someone stealing your content is much lower.

Final Thoughts

These methods should only be used if you have a concern that someone will actually copy your content. It could be considered a bad UI/UX tactic to disable right clicking and text copying.

Save 4 Later
Email liked links to yourself