blob: cd4f8b991927e3612e2a7865d0e74237db5e7b4d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
<header><h1>draggable</h1></header><div class="section-content">
<p>The <code>draggable</code> <a href="../global_attributes">global attribute</a> is an <a href="https://developer.mozilla.org/en-US/docs/Glossary/Enumerated">enumerated</a> attribute that indicates whether the element can be dragged, either with native browser behavior or the <a href="https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API">HTML Drag and Drop API</a>.</p> <p> The <code>draggable</code> attribute may be applied to elements that strictly fall under the <a href="https://developer.mozilla.org/en-US/docs/Glossary/Namespace">HTML namespace</a>, which means that it cannot be applied to <a href="https://developer.mozilla.org/en-US/docs/Web/SVG">SVGs</a>. For more information about what namespace declarations look like, and what they do, see <a href="https://developer.mozilla.org/en-US/docs/Web/SVG/Namespaces_Crash_Course">Namespace crash course</a>. </p> <p><code>draggable</code> can have the following values:</p> <ul> <li>
<code>true</code>: the element can be dragged.</li> <li>
<code>false</code>: the element cannot be dragged.</li> </ul> <div class="notecard warning" id="sect1"> <p><strong>Warning:</strong> This attribute is <em><a href="https://developer.mozilla.org/en-US/docs/Glossary/Enumerated">enumerated</a></em> and not <em>Boolean</em>. A value of <code>true</code> or <code>false</code> is mandatory, and shorthand like <code><img draggable></code> is forbidden. The correct usage is <code><img draggable="false"></code>.</p> </div> <p>If this attribute is not set, its default value is <code>auto</code>, which means drag behavior is the default browser behavior: only text selections, images, and links can be dragged. For other elements, the event <a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/dragstart_event"><code>ondragstart</code></a> must be set for drag and drop to work, as shown in this <a href="https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API/Drag_operations">comprehensive example</a>.</p>
</div>
<h2 id="specifications">Specifications</h2>
<div class="_table"><table class="standard-table">
<thead><tr><th scope="col">Specification</th></tr></thead>
<tbody><tr><td><a href="https://html.spec.whatwg.org/multipage/dnd.html#the-draggable-attribute">HTML Standard <br><small># the-draggable-attribute</small></a></td></tr></tbody>
</table></div>
<h2 id="browser_compatibility">Browser compatibility</h2>
<div class="_table"><table>
<thead>
<tr id="bct-browser-type">
<th></th>
<th colspan="6">Desktop</th>
<th colspan="6">Mobile</th>
</tr>
<tr id="bct-browsers">
<th></th>
<th>Chrome</th>
<th>Edge</th>
<th>Firefox</th>
<th>Internet Explorer</th>
<th>Opera</th>
<th>Safari</th>
<th>WebView Android</th>
<th>Chrome Android</th>
<th>Firefox for Android</th>
<th>Opera Android</th>
<th>Safari on IOS</th>
<th>Samsung Internet</th>
</tr>
</thead>
<tbody><tr>
<th><code>draggable</code></th>
<td class="bc-supports-yes">4</td>
<td class="bc-supports-yes">12</td>
<td class="bc-supports-yes">2</td>
<td class="bc-supports-yes">Yes</td>
<td class="bc-supports-yes">12</td>
<td class="bc-supports-yes">5</td>
<td class="bc-supports-yes">4.4</td>
<td class="bc-supports-yes">18</td>
<td class="bc-supports-yes">4</td>
<td class="bc-supports-yes">14</td>
<td class="bc-supports-yes">4.2</td>
<td class="bc-supports-yes">1.0</td>
</tr></tbody>
</table></div>
<h2 id="see_also">See also</h2>
<div class="section-content"><ul> <li>All <a href="../global_attributes">global attributes</a>.</li> </ul></div><div class="_attribution">
<p class="_attribution-p">
© 2005–2023 MDN contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>
<a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/draggable" class="_attribution-link">https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/draggable</a>
</p>
</div>
|