Disable dragging an image from an HTML page using CSS

Image drag and drop is a user-friendly concept that makes it easy to move an image to a different location by dragging it.

It allows the user to click and hold the mouse button over an image, drag it to another location, and release the mouse button to drop an image there.

However, the image dragging feature can be disabled using CSS.

Method 1:   Add draggable="false" to your image tag in html code

img src="img/img-1.jpg" id="myImage" draggable="false"

Method 2:   Add "pointer-events: none;" to your image id in css code

pointer-events: none;


  Adarsh Vishwakarma

Leave a Comment

All Rights are Reserved