HTML draggable global attribute
Thedraggable
global attribute is anenumerated attribute that indicates whether the element can be dragged, either with native browser behavior or theHTML Drag and Drop API.
Thedraggable
attribute may be applied to elements that strictly fall under theHTML namespace, which means that it cannot be applied toSVGs.For more information about what namespace declarations look like, and what they do, seeNamespace crash course.
draggable
can have the following values:
true
: the element can be dragged.false
: the element cannot be dragged.
Warning:This attribute isenumerated and notBoolean. A value oftrue
orfalse
is mandatory, and shorthand like<img draggable>
is forbidden. The correct usage is<img draggable="true">
.
If this attribute is not set, its default value isauto
, which means drag behavior is the default browser behavior: only text selections, images, and links can be dragged. For other elements, the eventondragstart
must be set for drag and drop to work, as shown in thiscomprehensive example.
Specifications
Specification |
---|
HTML # the-draggable-attribute |