Disable Selection of text on Web page

Disabling text selection on a web page can be useful in certain scenarios, such as preventing users from copying content or protecting sensitive information. While completely preventing text selection may not always be desirable from a usability standpoint, there are situations where it can be necessary. In this blog post, we’ll explore how to disable text selection on a web page using CSS and JavaScript.

Why Disable Text Selection?

Before we delve into the technical details, let’s briefly discuss why one might want to disable text selection on a web page:

  1. Protecting Content: Preventing users from selecting and copying content can help protect intellectual property or sensitive information.
  2. User Experience: In some cases, preventing text selection can improve the user experience by guiding users to interact with content in specific ways, such as through buttons or interactive elements.
  3. Presentation: For certain design aesthetics or interactive elements, disabling text selection can ensure that the layout remains intact and prevents unintended selection of text.

Html Structure:-

<!DOCTYPE html>
<html>
<head>
   <title>Disable selection of text on web page - Wizbrand</title>
   <style type="text/css">
        body{
            user-select: none; /* supported by Chrome and Opera */
            -webkit-user-select: none; /* Safari */
            -khtml-user-select: none; /* Konqueror HTML */
            -moz-user-select: none; /* Firefox */
            -ms-user-select: none; /* Internet Explorer/Edge */
        }
   </style>
</head>
<body>
  
<h3>How to disable text selection on html web page using JQuery?</h3>
  
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
  
</body>
</html>

Disabling Text Selection with CSS

<style type="text/css">
        body{
            user-select: none; /* supported by Chrome and Opera */
            -webkit-user-select: none; /* Safari */
            -khtml-user-select: none; /* Konqueror HTML */
            -moz-user-select: none; /* Firefox */
            -ms-user-select: none; /* Internet Explorer/Edge */
        }
   </style>

Output:-

Hopefully, It will help you ..!!!

Related Posts

Renting a Bike, Scooter, or Car in Japan: A Rider’s Honest Guide to Roads, Rules, and Fleet Tools

Introduction Ask any rider about Japan, and their eyes light up. The roads feel almost unfair. Smooth surfaces. Sharp markings. Drivers who actually follow the rules. Add…

Read More

How Long Does Pilot Training Take? Real Timelines for Every License

Introduction Most people who dream of flying never start. Not because they lack talent. Not because they lack passion. They simply never find a clear answer to…

Read More

Free Blogging Platform Guide: Create a Blog for Free, Publish Articles Online, and Join a Writing Community

Introduction You have ideas worth sharing. Maybe you want to write about technology. Maybe you want to document your travels. Or maybe your business needs a place…

Read More

Offer Letter Management Software: How to Speed Up Candidate Acceptance

Hiring a talented person feels great. The interview went well, and the team said yes to you. Everyone smiles and waits for day one. But then the…

Read More

How TheDataOps Explains Predictive Maintenance in Pipelines

Your data pipelines break down at the worst possible time. You wake up to angry texts from your team because morning reports are blank. You spend hours…

Read More

Customer Reviews and Ratings: Why Verified Feedback Matters Most

Introduction Shopping online in India is exciting today. You can find millions of gadgets, appliances, and tools with just one click. Yet, this massive choice creates a…

Read More
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
0
Would love your thoughts, please comment.x
()
x