You must have seen certain websites where you cannot select/copy text to clipboard be it web or mobile devices. i.e unselectable elements like div or p. If you want to implement this functionality to your webpage then you can achieve it using simply pure CSS properties/attributes.
Properties to Disable copy to clipboard options.
For iOS and Safari browsers
-webkit-touch-callout : none
-webkit-user-select:none
webkit-touch-callout : none: No callout option will be shown when the user's touch and holds on the element with this attribute.
webkit-user-select : none: You cannot select text on Safari on macOS, if you do a right-click no options to copy is displayed.
For Mozilla firefox browser
-moz-user-select: none;
-moz-user-select: when set to none, text cannot be selected and copied to clipboard on Mozilla firefox browsers.
For Windows Internet Explorer (ie) browsers
-ms-user-select: none; user-select: none;
-ms-user-select: makes text unselectable in ie web and mobile browsers.
For Opera desktop and web browsers
-o-user-select: none;; user-select: none;
-o-user-select: none: makes text unselectable in ie web and mobile Opera browsers.
Example :<div style="-webkit-user-select: none;
-khtml-user-select: none;
-webkit-touch-callout : none
-moz-user-select: none;
-o-user-select: none;
user-select: none; background:#ffff22">
This text cannot be copied to the clipboard. Just try doing it :D </div>
Now let's create a div tag and add the above code in style attribute to check if it works!
Demo :- How to create a circular Image using pure CSS Code
- Horizontally Center Align tag in HTML using CSS
- Add scroll to div element in HTML Css
- Change CSS Background Opacity with Examples
- How to make text bold using CSS
- How to place two div elements next to each other
- Vertically Center Text in a DIV Element
- align image at middle of div element
- Tailwind CSS Hello World Example
- How to make div or text in html unselectable using CSS
- Only Chessboard using HTML and CSS Code Example
- Simple CSS Grid Example
- How to set CSS background-Image Property
- CSS Background Opacity with Examples
- reCAPTCHA Implementation Tutorial
- List of 32 CSS cursors web developers must know about
- How to Vertically Center Align Text in a Div using CSS Code Example
- 10 Must Know CSS Border Styles with Examples
- Tutorial : Simple Lightweight Pure CSS based Vertical Navigation Menu
- CSS: Apply opacity only for div background and not text
- Set Falling Show on Website for Christmas using Pure CSS Code
- How to make jsfiddle bootstrap ready
- Elegant CSS Box Shadows Ideas
- Responsive Web Design with CSS Media Queries: A Beginner's Tutorial [Updated for 2023]
- How to Center Align Image in Bootstrap
More Posts:- SharePoint installation error - Setup is unable to proceed due to the following error This product requires Microsoft .Net Framework 4.5 - SharePoint
- [Fix] reCAPTCHA not working in Web Browser - Google
- Convert Java Object to JSON using Jackson Library - Java
- Fix Microsoft Teams Error code - 107 - Teams
- [Fix] Microsoft Teams No Network Connection Please check your network settings and try again. [2603] - Teams
- How to revert a single file from Git Repo - Git
- How to stop MongoDB Server running on Ubuntu - Ubuntu
- Can we move apps like WhatsApp, Facebook to external MicroSD card - WhatsApp