How to prevent an image from being draggable or selectable without using CSS?

Spread the love

Sometimes, we want to prevent an image from being draggable or selectable without using CSS.

In this article, we’ll look at how to prevent an image from being draggable or selectable without using CSS.

How to prevent an image from being draggable or selectable without using CSS?

To prevent an image from being draggable or selectable without using CSS, we set the user-drag property.

For instance, we write

.selector {
  user-drag: none;
  -webkit-user-drag: none;
  user-select: none;
  -moz-user-select: none;
  -webkit-user-select: none;
  -ms-user-select: none;
}

to set the user-drag property to noine to disable dragging on the elements with class selector.

Conclusion

To prevent an image from being draggable or selectable without using CSS, we set the user-drag property.

Leave a Reply

Your email address will not be published.