HTML draggable Global Attribute
Description
The draggable HTML global attribute specifies whether an element is draggable or not. It can be applied to any HTML element, but it has no effect on SVG elements.
The draggable attribute can have two values:
true: The element can be dragged.false: The element cannot be dragged.
If the draggable attribute is not set, its default value is auto. This means that the drag behavior will be the default browser behavior: only text selections, images, and links can be dragged. For other elements, the ondragstart event must be set for drag and drop to work.
The draggable attribute is often used in drag and drop operations, where users can drag elements from one location to another. For example, you could use the draggable attribute to create a drag-and-drop list of items, or to allow users to move elements around on a canvas.
Here is an example of how to use the draggable attribute:
<div draggable="true">
<p>This element can be dragged.</p>
</div>
When the user hovers over this element, they will see a cursor that indicates that the element can be dragged. If the user clicks and holds on the element, they can drag it to a new location.
Syntax
<element draggable="true | false | auto">
Values
- trueIndicates that the item can be dragged.
- falseIndicates that the item cannot be dragged.
- autoUses browser settings.
Example
Browser Support
The following information will show you the current browser support for the HTML draggable global attribute. Hover over a browser icon to see the version that first introduced support for this HTML global attribute.
This global attribute is supported by all modern browsers.
Desktop
Tablets & Mobile
Last updated by CSSPortal on: 14th October 2023
