
- CSS Tutorial
- CSS - Home
- CSS - Introduction
- CSS - Syntax
- CSS - Inclusion
- CSS - Measurement Units
- CSS - Colors
- CSS - Backgrounds
- CSS - Fonts
- CSS - Text
- CSS - Images
- CSS - Links
- CSS - Tables
- CSS - Borders
- CSS - Margins
- CSS - Lists
- CSS - Padding
- CSS - Cursors
- CSS - Outlines
- CSS - Dimension
- CSS - Scrollbars
- CSS Advanced
- CSS - Visibility
- CSS - Positioning
- CSS - Layers
- CSS - Pseudo Classes
- CSS - Pseudo Elements
- CSS - @ Rules
- CSS - Text Effects
- CSS - Media Types
- CSS - Paged Media
- CSS - Aural Media
- CSS - Printing
- CSS - Layouts
- CSS - Validations
- CSS3 Tutorial
- CSS3 - Tutorial
- CSS3 - Rounded Corner
- CSS3 - Border Images
- CSS3 - Multi Background
- CSS3 - Color
- CSS3 - Gradients
- CSS3 - Shadow
- CSS3 - Text
- CSS3 - Web font
- CSS3 - 2d transform
- CSS3 - 3d transform
- CSS3 - Animation
- CSS3 - Multi columns
- CSS3 - User Interface
- CSS3 - Box Sizing
- CSS Responsive
- CSS - Responsive Web Design
- CSS References
- CSS - Questions and Answers
- CSS - Quick Guide
- CSS - References
- CSS - Color References
- CSS - Web browser References
- CSS - Web safe fonts
- CSS - Units
- CSS - Animation
- CSS Resources
- CSS - Useful Resources
- CSS - Discussion
Is it possible to prevent the users from taking screenshot of webpage?
While browsing through the internet a user might find the need to capture something in order to present or to show to someone, but sometimes there might be sensitive information on a webpage which the developer might not want the user to screenshot it.
The user can press the function key along with windows key and space bar to take a screen shot. In MacOS we would have to use the command and shift and 3 for taking a screenshot.
In this article, we are going to have a look at how can we prevent the user from taking a screenshot of the webpage.
How to prevent the user to take screenshots?
The commands of taking a screenshot cannot be disabled as these are the inbuilt features and are controlled by the OS. We can use HTML, CSS and JavaScript but still can’t block users from taking screenshots. It is a difficult task to prevent the user from taking screenshots as the user can copy and paste the content of the website or can also use some third party software to do so.
Whereas, we can use some methods to avoid the user taking screenshots of the webpage to some extent.
Example
In the following example, we inserted some text and then enclosed it within a div and then in the CSS section. After that, we used the media query and set the display to none. This way the content will be visible to the user but the user will not be able to print the screen.
<!DOCTYPE html> <html lang="en"> <head> <title>Example of disabling the printing </title> <style> @media print { html, body { display: none; } } </style> </head> <body> <div> Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. </div> </body> </html>
Example
In the next example, we will be warning the user by displaying a message on the screen to not to copy or screenshot the content of the web-page.
<!DOCTYPE html> <html lang="en"> <head> <title>Example of disabling the printing </title> <style> html { user-select: none; } </style> </head> <body> <div> Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. </div> </body> </html>
In the above code, we used the same paragraph that we used in the previous example and this time in the CSS section, we used the user-select property and set its value to none. Now the user will be able to see the content on the screen but will not be able to select it. The output will be the following
Example
In the next example, we will be warning the user by displaying a message on the screen to not to copy or screenshot the content of the web-page.
<!DOCTYPE html> <html lang="en"> <head> <title>Example of printing a warning message to the user </title> <script> alert("Please!! do not try to take any kinds of screenshot of the content"); </script> </head> <body> <div> Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. </div> </body> </html>
In the above code, we again used the same paragraph and used a single line of code from JavaScript, which will give a warning to the user, if the user is trying to take a screenshot of the webpage.
Conclusion
It is impossible to completely prevent the user from taking any kind of screenshots or copying and then pasting your content on some other third party website. The printing screen is an inbuilt feature which every operating system like windows and MacOS offers and these features can’t be disabled as they are controlled by the OS. We can only prevent the user from copying the content to a certain degree and not more than that.
- Related Articles
- How do I prevent Android taking a screenshot when my app goes to the background?
- How to get screenshot of full webpage using Selenium and Java?
- JavaScript: How to allow users to change the font-size of a webpage?
- Creating a screenshot taking website in Django
- Is it possible to scroll down in a webpage using Selenium Webdriver programmed on Python?
- Is it possible to extract petroleum from under the sea bed?
- Is it possible to display substring from object entries in JavaScript?
- Is it possible to predict the occurrence of an earthquake?
- What is Bluesnarfing and how to prevent it?
- Is it possible to return a list of specific values from a MongoDB query?
- Is it possible to exclude subclasses from the results displayed in backoffice in SAP?
- Risks and Possible Side Effects Related to Taking the Herbal Product
- Is it possible to return a list of specific values from a query in MongoDB?
- What is Harpooning? (How it Works, How to Prevent)
- What is an Enumeration Attack? How to Prevent It?
