Re: [csswg-drafts] Proposal for a user interaction :drag pseudo-class (#11584)

On the call we requested more clarification. I believe the request is pretty clear in the OP, but the proposed pseudo is a bit misguiding. The OP reads:

> … enable developers to apply styles when an element is being actively dragged by the user

So the pseudo would most likely be `:dragged` instead of `:drag`.

Having this available in CSS would remove the need for this bit of JavaScript:

```js
element.addEventListener("dragstart", (e) => {
  event.target.classList.add("dragged");
});
element.addEventListener("dragend", (e) => {
  event.target.classList.remove("dragged");
});
```

Check out [this demo](https://codepen.io/bramus/pen/zxqeNQd/4fd39b823242310ef150485c7df3e5c0) for an example. The dragged item is given a lightblue background and a lighter opacity.

Note: The styling of the drag-image is food for a separate issue: https://github.com/w3c/csswg-drafts/issues/13198

-- 
GitHub Notification of comment by bramus
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/11584#issuecomment-3719776629 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Wednesday, 7 January 2026 16:46:43 UTC