DEV Community

Cover image for How to add some security, that anyone not copy your text ? Using CSS!
Faria Waseer
Faria Waseer

Posted on

How to add some security, that anyone not copy your text ? Using CSS!

It is very common that everyone can easily copy texts from websites, with and the minor problem is that if anybody touches screen for a while automatically test select and options occurs -- select all copy past extra, its seems come time ugly & if you want to add some security to text that anyone don't copy than you use this also.
Now write to need little bit css!

.container{
    User-select:none;
}
Enter fullscreen mode Exit fullscreen mode

I hope you will enjoy this CSS TipπŸ’‘

Top comments (4)

Collapse
 
moopet profile image
Ben Sinclair

I think this is good to know, but in practice it's almost always a very bad idea - it doesn't stop people from copying the text, it just makes it one step more tricky (view-source, then copy, for example).

Are there any legitimate reasons to want people not to be able to copy text they can see? Yes, but they're pretty rare.

On the other hand, there are lots of reasons people might have for copying text which are perfectly reasonable. Some examples:

  • I want to check that something you wrote isn't plagiarised, so I'll paste it into a search engine
  • I want to use the code or credentials in your tutorial (if you had User-selector: none on a parent element on this post then I couldn't copy the code...)
  • You list an email address or product without linking to it and I don't want to type it myself in case I make a mistake
  • If a user doesn't know what a word you used means, they can't highlight it then right-click to look it up in the dictionary (on some devices)
  • In dense blocks of text, sometime users will highlight a section with the mouse to make it easier to read
  • Some people might want a paragraph read out using text-to-speech but not use a screen reader, and work by highlighting the text and triggering the speech action
Collapse
 
fairywsr profile image
Faria Waseer

I understand Your Point of view
But User-selector Does not effect any link or any highlight. This property use for text ..
Your first point is valid that how to copy e-mail or products name etc because they are also written as text, we need to work on this..

Collapse
 
Sloan, the sloth mascot
Comment deleted
Collapse
 
fairywsr profile image
Faria Waseer

Yeah I today use this property in Body
And it works,