Secure our Web content through HTML

In today's world there more than 1 billion websites on the internet. Some are Informative websites,  some are E-commerce & some are Web apps. Each website has contents.

What is Web content?

Web content is the textual & visual content that is encountered as part of the user experience on websites.

The content is of two types:

  1. Media file (Images, Videos, Gifs).
  2. Text.

To secure the website content in HTML we use some methods in our code.

As earlier I said there are two types of content: Media & Text.

So for both, there are different methods to secure it.

1. Media type:
Method 1:

Add draggable="false" to your image tag in HTML code

<img src="img/img-1.jpg" draggable="false"/>
Method 2:

Add "pointer-events: none;" to your image id in CSS code

<img src="img/img-1.jpg" id="myImage"/>

<style>
#myImage{pointer-events: none;}
</style>

2. Text type:
Method 1:

Add "unselectable" class in the body or any div then give a style in s CSS code to it.

<body class="unselectable"></body>
or
<div class="unselectable"></div>

<style>
.unselectable{-moz-user-select:none; -webkit-user-select:none;}
</style>

Method 2:

Add "onselectstart="return false;"" attribut in the body or any div of the HTML tag.

<body onselectstart="return false;"></body>
or
<div onselectstart="return false;"></div>

14th-May-2021

Adarsh Vishwakarma


Share the Post

Feedback

Comment

Leave a Comment