How to Use HTML5 Drag and Drop Feature with Text and Image Elements
This article will teach you how to make use of the drag and drop functionality of HTML5.
Drag and Drop an Element
The HTML5 drag and drop functionality enables users to drag and drop elements to different locations, including other applications. When an element is being dragged, a translucent representation of the element follows the mouse pointer.
The draggable
attribute is an HTML5 attribute that can be applied to elements to make them draggable, allowing users to move them or
perform drag-and-drop operations. This attribute is especially useful for creating interactive user interfaces and enhancing the overall user experience on web pages.
When the draggable
attribute is applied to an element, it can have one of two values:
draggable=true
: This value indicates that the element is draggable, and users can initiate drag operations on it.draggable=false
: This value indicates that the element is not draggable, and users cannot initiate drag operations on it.
To illustrate how this feature works, let's explore the following example:
Drag and Drop
Drag and drop the image into a drop box:
Also drag me