HTML draggable Attribute

Beginner
⏱️ 6 min read
📚 Updated: Jun 2026
🎯 3 Examples
Interaction & UI

What You’ll Learn

The draggable attribute is a global HTML attribute that controls whether an element can be dragged by the user. Set it to true to make a box, list item, or image a drag source. Pair it with the HTML Drag and Drop API (dragstart, dragover, drop) to build interactive interfaces.

01

Global

Most elements.

02

true / false

Enable or block.

03

auto

Browser default.

04

Drag Source

Starts a drag.

05

JS Events

drop targets.

06

.draggable

Toggle in JS.

Purpose of draggable

The primary purpose of the draggable attribute is to define whether an element can be picked up and dragged with the mouse or touch (where supported). It is the HTML-side switch that marks an element as a draggable item in the browser’s native drag-and-drop system.

Use it for kanban boards, sortable lists, file upload drop zones, or any UI where users rearrange content. Remember: draggable only enables dragging from the source element. Drop targets need separate event handlers.

💡
Attribute + events

draggable="true" starts the drag. Handle dragstart to set data, dragover with preventDefault() on targets, and drop to complete the action.

📝 Syntax

Add draggable to any element you want the user to drag:

draggable.html
<div class="card" draggable="true">

  Drag me

</div>

Syntax Rules

  • Enumerated attribute: true, false, or auto.
  • Default is auto for most elements (usually not draggable).
  • Use draggable="true" to explicitly enable dragging on divs, spans, and custom widgets.
  • Combine with CSS cursor: grab and user-select: none for clearer UX.

💎 Values

The draggable attribute accepts three keyword values:

  • true — Element can be dragged by the user.
  • false — Element cannot be dragged (explicitly disabled).
  • auto — Default. Browser decides; images and links may be draggable in some cases.
draggable-values.html
<div draggable="true">Draggable</div>

<div draggable="false">Not draggable</div>

<img src="photo.png" draggable="false" alt="Block image drag">

⚡ Quick Reference

ItemDetailsNotes
ScopeGlobal attributeMost HTML elements
Valuestrue, false, autoDefault: auto
RoleDrag source onlyNot a drop target
Key eventsdragstart, dragendOn draggable element
Drop eventsdragover, dropOn target zone
JS propertyelement.draggableBoolean true/false

Applicable Elements

ElementSupported?Notes
<div>, <span>, <li>YesCommon custom drag items
<img>YesOften draggable by default; use false to block
<a href>YesLinks may drag by default with auto
<button>, <input>YesRare; consider UX carefully

draggable + drag events

StepWhat to usePurpose
1. Enable dragdraggable="true"User can start dragging
2. Drag startsdragstart + dataTransferStore drag payload
3. Over targetdragover + preventDefault()Allow dropping
4. Dropdrop handlerComplete the action

Examples Gallery

A draggable box, JavaScript toggling, and a simple drop zone with drag events.

Example — Draggable Box

Make a div draggable with styling that hints at drag behavior:

draggable-box.html
<div class="box" draggable="true">Drag me</div>
Try It Yourself

How It Works

draggable="true" marks the element as a drag source. The browser shows a drag ghost while the user moves it.

Dynamic Values with JavaScript

Toggle drag behavior with the draggable property:

toggle-draggable.html
<div id="dynamicDraggable">Drag me</div>



<script>

  document.getElementById("dynamicDraggable").draggable = true;

</script>
Try It Yourself

How It Works

The DOM property accepts boolean true or false. Use it when drag should depend on app state or permissions.

Example — Drag-and-Drop Zone

Combine draggable with drop event handlers:

drag-drop.html
<div id="item" draggable="true">Drag me</div>

<div id="zone">Drop here</div>



<script>

  zone.addEventListener("dragover", e => e.preventDefault());

  zone.addEventListener("drop", e => { e.preventDefault(); zone.appendChild(item); });

</script>

How It Works

draggable enables the drag. The drop zone must call preventDefault() on dragover so the browser accepts the drop.

♿ Accessibility

  • Do not rely on drag alone — Provide keyboard alternatives (buttons, menus) for reordering or moving items.
  • Announce changes — Use live regions when drag-and-drop updates content for screen reader users.
  • Clear affordance — Use visible handles or labels so users know what is draggable.
  • Focus management — After a drop, ensure focus follows the moved element logically.

🧠 How draggable Works

1

Element has draggable=true

Browser allows drag initiation.

HTML
2

User starts dragging

dragstart fires; set dataTransfer data.

Event
3

Over drop target

dragover with preventDefault on target.

Target
=

Drop completes

drop handler moves or updates content.

Browser Support

The draggable attribute and HTML Drag and Drop API are supported in all modern browsers.

HTML5 · Fully supported

Native drag-and-drop

Chrome, Firefox, Safari, and Edge support draggable and related drag events.

97% Browser support
Google Chrome Fully supported
Full support
Mozilla Firefox Fully supported
Full support
Apple Safari Fully supported
Full support
Microsoft Edge Fully supported
Full support
draggable attribute 97% supported

Bottom line: Use draggable in modern apps; test touch and keyboard fallbacks on mobile.

💡 Best Practices

✅ Do

  • Use draggable=true only on intentional drag handles
  • Pair with dragstart, dragover, and drop handlers
  • Style with cursor: grab and user-select: none
  • Provide keyboard alternatives for accessibility
  • Block image drag with draggable=false when needed

❌ Don’t

  • Expect draggable alone to implement full DnD
  • Make entire pages draggable by default
  • Forget preventDefault on dragover for drop zones
  • Rely only on mouse drag for critical actions
  • Drag sensitive data without user confirmation

Conclusion

The draggable attribute is a valuable tool for adding drag-and-drop capabilities to web pages. It marks elements as drag sources with true, blocks dragging with false, or leaves the decision to the browser with auto.

Combine it with the Drag and Drop API for complete interactions, toggle it dynamically with JavaScript, and always consider keyboard-accessible alternatives for inclusive design.

Key Takeaways

Knowledge Unlocked

Five truths every developer should know about draggable

Bookmark these before building drag UI.

5
Core concepts
02

true / false

Explicit control.

Values
⚙️ 03

auto

Default value.

Default
📦 04

+ Events

Need drop JS.

API
05

Keyboard alt

A11y matters.

A11y

❓ Frequently Asked Questions

It controls whether an element can be dragged by the user as a drag source in the HTML Drag and Drop API.
true, false, and auto. The default is auto for most elements.
No. You also need JavaScript event handlers like dragstart, dragover, and drop for full drag-and-drop behavior.
Set draggable="false" on the <img> element to prevent the browser from dragging the image.
Yes. Set element.draggable = true or false based on your application logic.
Yes in all modern desktop browsers. Test touch devices and provide non-drag alternatives for accessibility.

Build drag-and-drop UI

Practice draggable="true" with a drop zone in the Try It editor.

Try drag-and-drop example →

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.

3 people found this page helpful