HTML global attributeGlobal attributes

draggable

Specifies whether an element can be dragged with the mouse.

Applies to
All HTML elements
On this page

Example

#
HTML
<style>
  .chip { display: inline-block; padding: 6px 12px; margin: 4px; border-radius: 99px; background: #312e81; cursor: grab; }
</style>

<p>Try dragging the tiles:</p>
<span class="chip" draggable="true">Can be dragged</span>
<span class="chip" draggable="false">Cannot</span>
Preview

Definition and usage

#

The draggable attribute enables or disables dragging of an element as part of the drag and drop mechanism. Images and links can be dragged by default; other elements only once you set draggable="true".

Dragging alone is only half the work. For anything to happen on drop, JavaScript has to handle the dragstart, dragover and drop events.

The value has to be given explicitly as true or false. Writing just the word draggable without a value does not work like a boolean attribute.

Syntax

#
Syntax
<element draggable="true | false">…</element>

Values

#
  • true

    The element can be dragged.
  • false

    Dragging is disabled, including for images and links.

Browser support

#

Widely available

Works in all modern browsers, phones included. You can use it without worry.

  • Chrome
  • Edge
  • Firefox
  • Safari

Good practices

#
  • Drag and drop works poorly on touch screens. Provide another way too, for example “up” and “down” buttons.
  • Set draggable="false" on images in a gallery if dragging gets in the way of scrolling.

Related entries

#

Spotted a mistake or missing an example? Write to us.