HTML draggable Attribute

Beginner
5 min read
Updated: Oct 2026
3 examples
Live preview

Definition and Usage

The draggable global attribute is an enumerated flag that says whether an element can be dragged (native behavior or the HTML Drag and Drop API). Valid values are true and false. If you omit it, the default is auto.

With auto, browsers typically allow dragging text selections, images, and links. Other elements need draggable="true" (and usually a dragstart handler) to participate. Dropping still needs JavaScript on the target.

Baseline · Widely available.

Not deprecated and not experimental. Stable across modern browsers since about July 2015. Applies to HTML elements (not SVG).

Not a boolean attribute.

Write draggable="true" or draggable="false". A bare draggable with no value is invalid — unlike disabled or readonly.

HTML Syntax

syntax.html
<element draggable=" true | false">

Omitted attribute ≈ auto. In JavaScript: element.draggable = true or false.

Attribute Values

Enumerated values (must be written explicitly):

ValueDescriptionTry it
trueElement can be draggedTry it
falseElement cannot be dragged (overrides default for images/links)Try it
auto (default)Browser default — selections, images, and links; others need trueTry it
+ drop eventsAttribute starts drag; dragover/drop complete the UITry it

Live Preview

Change draggable on the box, then try dragging it with the mouse.

A plain <div> is not draggable under auto — only with true.

Element

Drag me

draggable = "true"

HTML Examples

Short, copy-ready snippets. Use Try It Yourself for a live editor.

Example 1 — Make a Div Draggable

Ordinary elements need an explicit true value.

HTML
<div draggable="true">Drag me</div>
Try It Yourself

How It Works

  1. Set draggable="true" on the element (not bare draggable).
  2. Browser allows a drag gesture on that node.
  3. Default drop does nothing useful until you add handlers.
  4. Text selection inside may need Alt+drag (or keyboard) while dragging is enabled.

Example 2 — Turn Off Default Image Drag

Images are draggable under auto. Use false to block that.

HTML
<img src="/images/javascript.png" alt="Logo" width="96" height="96" draggable="false">

<img src="/images/javascript.png" alt="Logo (default drag)" width="96" height="96">
Try It Yourself

How It Works

  1. Images and links drag by default (auto).
  2. draggable="false" turns that off.
  3. Useful when a drag conflicts with UI (carousels, click handlers).
  4. Same idea works on anchors you do not want dragged.

Example 3 — Draggable Item + Drop Zone

Attribute starts the drag; events finish the drop.

HTML
<div id="item" draggable="true">Drag me</div>
<div id="zone">Drop here</div>

<script>
  var item = document.getElementById("item");
  var zone = document.getElementById("zone");

  item.addEventListener("dragstart", function (e) {
    e.dataTransfer.setData("text/plain", "item");
  });

  zone.addEventListener("dragover", function (e) {
    e.preventDefault(); // allow drop
  });

  zone.addEventListener("drop", function (e) {
    e.preventDefault();
    zone.appendChild(item);
  });
</script>
Try It Yourself

How It Works

  1. draggable="true" makes the source dragable.
  2. dragstart stores data with dataTransfer.setData.
  3. dragover must call preventDefault() or drop never fires.
  4. drop moves (or copies) the item into the target.

Edge Cases & Pitfalls

Most bugs come from treating draggable like a boolean or forgetting drop handlers.

syntax

Bare draggable is invalid

Always use "true" or "false". Empty or missing values do not enable dragging the way boolean attributes do.

api

Attribute ≠ full DnD

Without dragover + preventDefault and a drop listener, the item flies back and nothing lands.

svg

HTML namespace only

Do not rely on draggable on SVG elements. Prefer HTML wrappers or other interaction patterns.

a11y

Offer a non-drag path

Pointer drag is hard for keyboard and many assistive tech users. Provide buttons or other controls that do the same job.

touch

Mobile support varies

HTML DnD is historically mouse-oriented. Test touch devices; consider Pointer Events or libraries when touch is required.

Browser Support

draggable is an HTML global attribute in the browser. It is not a Node.js, Deno, or Bun API.

✓ Baseline · Widely available

draggable

Supported in modern Chrome, Firefox, Safari, and Edge. Drag-and-drop UX still differs on touch devices and for keyboard users.

96% Global support (approx.)
Google Chrome 4+
Full support
Mozilla Firefox 2+
Full support
Apple Safari 5+
Full support
Microsoft Edge 12+
Full support
Opera 12+
Full support
Samsung Internet Modern
Full support
Internet Explorer 9+
Supported
draggable Widely supported

Bottom line: Safe to use on modern sites. Pair with JS drop handlers and accessible alternatives — the attribute alone is only the drag source hint.

Key Takeaways

  • Enumerated: use "true" or "false" — not a bare flag.
  • Default auto: selections, images, and links; other nodes need true.
  • Drops need JS: dragover + preventDefault, then drop.
  • A11y: always offer a non-drag way to do the same action.

One line: draggable="true|false" controls the drag source — drop zones still need events.

Frequently Asked Questions

It is a global enumerated attribute that says whether an element can be dragged. Use draggable="true" or draggable="false". If omitted, the default is auto (browser default: text selections, images, and links).
No. It is enumerated. You must write true or false explicitly. A bare draggable with no value is invalid and does not mean true.
No. It only allows the element to start a drag. Drop targets need JavaScript (at least preventDefault on dragover, plus a drop handler).
auto is the default when the attribute is omitted. Images, links, and text selections are draggable; other elements are not unless you set true or handle dragstart.
No. MDN notes it applies to elements in the HTML namespace, not SVG. Use the HTML Drag and Drop API patterns carefully with SVG or other approaches.
Use element.draggable = true or false (boolean property). That maps to the enumerated attribute values.

Next: enctype

How a form encodes data when it is submitted to the server.

enctype tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful