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:- Add Smiley and Emoji on Images Tool - Tools
- Fix: Error creating bean with name securityConfig: Unsatisfied dependency expressed - NoSuchBeanDefinitionException: No qualifying bean of type - Java
- Git Config Command - A Deep Dive - Git
- Fix: TextEdit Open Html as Plain Text Code - MacOS
- Managed Metadata error - The data returned from the tagging UI was not formatted correctly - SharePoint
- Country ISO Codes List - Java
- Fix: nano is not recognized as an internal or external command - Windows PowerShell - Powershell
- How to show Videos on SharePoint Page - SharePoint