YouTip LogoYouTip

Att Global Draggable

## HTML draggable Attribute The `draggable` attribute is an HTML global attribute that specifies whether an element can be dragged by the user using the browser's native Drag and Drop API. --- ## Browser Support The `draggable` attribute is widely supported across all modern web browsers: * **Google Chrome**: Supported * **Mozilla Firefox**: Supported * **Microsoft Edge / Internet Explorer**: IE 9+ and Edge supported * **Safari**: Supported * **Opera**: Supported *Note: Internet Explorer 8 and earlier versions do not support the `draggable` attribute.* --- ## Definition and Usage * The `draggable` attribute explicitly defines whether an element is eligible for drag-and-drop operations. * **Default Behaviors**: By default, only text selections, images (``), and links (`` with an `href` attribute) are draggable by the browser. To make other elements (like `
`, `

`, or `

  • `) draggable, you must set their `draggable` attribute to `true`. * To learn how to handle the dragged data and drop events, please refer to tutorials on the **HTML5 Drag and Drop API**. --- ## HTML 4.01 vs. HTML5 The `draggable` attribute is a new global attribute introduced in **HTML5**. --- ## Syntax ```html ``` ### Attribute Values | Value | Description | | :--- | :--- | | `true` | Specifies that the element is draggable. | | `false` | Specifies that the element is not draggable. | | `auto` | Uses the browser's default behavior (default). | --- ## Code Examples ### Basic Example: Making a Paragraph Draggable By default, a `

    ` element cannot be dragged. Setting `draggable="true"` enables the dragging visual effect. ```html

    This is a draggable paragraph. Try dragging this text!

    ``` ### Complete Implementation: Drag and Drop To make a drag-and-drop operation fully functional, you must combine the `draggable` attribute with JavaScript event listeners (`ondragstart`, `ondragover`, and `ondrop`). ```html HTML5 Drag and Drop Demo

    Drag the green box into the dashed rectangle:

    Drag Me!
    ``` --- ## Important Considerations 1. **Boolean-like but Enumerated**: Unlike some HTML attributes, `draggable` is an *enumerated* attribute, not a boolean one. This means you must explicitly write `draggable="true"` or `draggable="false"`. Simply writing `
    ` is not recommended and may lead to inconsistent browser behavior. 2. **User Experience**: When making elements draggable, it is best practice to update their CSS cursor property (e.g., `cursor: move;`) to visually signal to users that the element can be interacted with. 3. **Disabling Defaults**: If you want to prevent images or links from being dragged, you can explicitly set them to `draggable="false"`.
    ← Att Global DropzoneAtt Global Dir β†’
  • YouTip © 2024-2026 | Home | Learn Technology, Build Dreams!

    All content is for educational and learning purposes only.