Computer projects
Disabling text selection and copying on a webpage with CSS
To prevent dragging to select text with the mouse and disable selecting or copying page content, simply add the following CSS to the body's style.
/* css style: */
html,body{
-moz-user-select: none;
-khtml-user-select: none;
user-select: none;
}
<div unselectable="on" onselectstart="return false;" style="-moz-user-select:none;"> some text </div>
Notes: unselectable is for IE; onselectstart is for Chrome and Safari; -moz-user-select is specific to Firefox.
Published 05/05/2018 · Krunk Zhou
Join the conversation