Disable Text Selection Highlighting Using CSS


There is a code snippet in CSS3 to disable text selection by user.
Code below is cross-browser and might work well on all of the latest browsers like Chrome, Firefox, Safari and IE10+.

1. Disable Text Selection Highlighting Of Whole Page

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

2. Disable Text Selection Highlighting Of Specific Element (e.g.: A Div) 

.unselect {
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
<div class="unselectable"> ...</div>


More Information can be found at below link :
https://developer.mozilla.org/en-US/docs/Web/CSS/user-select?redirectlocale=en-US&redirectslug=CSS/user-select

Comments

Popular posts from this blog

Show Full Post on Front Page of Ghost, Not Excerpt

Video Blogger Templates

5 Beautiful Dark Blogger Templates