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.
Fundamentals
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.
Foundation
📝 Syntax
Add draggable to any element you want the user to drag:
draggable.html
<divclass="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.
Reference
💎 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 enables the drag. The drop zone must call preventDefault() on dragover so the browser accepts the drop.
A11y
♿ 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.
Compatibility
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 ChromeFully supported
Full support
Mozilla FirefoxFully supported
Full support
Apple SafariFully supported
Full support
Microsoft EdgeFully supported
Full support
draggable attribute97% supported
Bottom line: Use draggable in modern apps; test touch and keyboard fallbacks on mobile.
Pro Tips
💡 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
Wrap Up
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.