CSS has no native way to react to the moment a user picks up an element and drags it. Handling that state today means reaching for JavaScript and toggling a class, as in the common classList.toggle() pattern. A proposal in the CSSWG drafts would change that by introducing a :drag pseudo-class that matches while an element is being actively dragged by the user.
Mapping the Drag and Drop API into CSS
The mechanics behind this are defined by the HTML Drag and Drop API, which fires a series of events on the dragged element:
dragstart, fired once when the drag begins;drag, fired repeatedly every few milliseconds during the drag;dragend, fired when the drag stops.
Consider a menu bar made of seven buttons:
<menu class="menu-bar">
<li><button>Home</button></li>
<li><button>Products</button></li>
<li><button>Services</button></li>
<li><button>About</button></li>
<li><button>Contact</button></li>
<li><button>Blog</button></li>
<li><button>Careers</button></li>
</menu>
Marking the bar draggable is a single attribute:
<menu class="menu-bar" draggable="true">
<!-- etc. -->
</menu>
In the current approach, an .is-dragging class holds the styles applied only while the element is in motion:
.is-dragging {
box-shadow: 0 4px 12px rgba(0 0 0 / 0.15);
background: #fff;
transform: translate(1px);
opacity: 0.2;
scale: 1.2;
}
Script then listens for the dragstart event and adds the class to .menu-bar, removing it once the element is dropped and the drag ends:
menuBar.addEventListener("dragstart", (event) => {
event.target.classList.add("is-dragging");
});
menuBar.addEventListener("dragend", (event) => {
event.target.classList.remove("is-dragging");
});
With that in place, the dragged menu bar keeps an image of itself in its original position, styled through .is-dragging. The :drag proposal compresses the whole scripting step into a rule that keys directly off drag state:
.menu-bar:drag {
cursor: grabbing;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
background: #fff;
transform: translate(1px);
opacity: 0.2;
scale: 1.2;
}
The Drag Feedback Image
There is a second, less-known extension point: the preview image, or the actual element that follows the cursor while dragging. It can be replaced with a custom <div> carrying its own styling:

That requires a bit more script, using dataTransfer.setDragImage():
const dragPreview = document.createElement("div");
dragPreview.textContent = "📦 Dragging...";
dragPreview.style.cssText = `
background: #fff6d6;
border: 2px dashed orange;
border-radius: 0.5rem;
color: #333;
padding: 0.5rem 1rem;
`;
document.body.appendChild(dragPreview);
// This replaces the default drag preview
event.dataTransfer.setDragImage(dragPreview, 0, 0);
// Remove after the event fires
setTimeout(() => dragPreview.remove(), 0);
The proposal attached to this problem is a second pseudo — ::drag-image — that could replace the preview without script, writing the styling directly in CSS:
::drag-image {
content: "📦 Dragging...";
padding: 0.5rem 1rem;
background: #fff6d6;
color: #333;
border: 2px dashed orange;
border-radius: 0.5rem;
}
Since the target here is a specific object rather than a state, a pseudo-element arguably fits better than a pseudo-class. The idea comes with an open issue encouraging a thumbs-up if it would be useful, and the CSSWG is already slated to discuss
:drag. If that specification work lands, the case for the pseudo-element gets pushed alongside it.Dedicated drag pseudos side-step the script round trip that a class toggle involves — fewer dependencies and less code to maintain. Both remain proposals for now. The open question is whether developers would reach for them, or consider them too far into territory JavaScript currently owns.



