The onwheel attribute is an event handler for the wheel event. It runs when the user rotates a mouse wheel (or a similar trackpad gesture) over the element. The event is a WheelEvent with deltaX, deltaY, and deltaZ.
It replaces the old non-standard onmousewheel. Do not confuse it with onscroll: wheel is input; scroll means the position changed.
Standard wheel event (replaces mousewheel).
Not deprecated. Prefer addEventListener("wheel", …) in scripts; the HTML attribute is the same handler.
Wheel ≠ scroll direction.
A wheel event may not scroll anything (unscrollable target, zoom with Ctrl). For scroll position, read scrollTop / scrollY in a scroll handler — not delta* alone.
Syntax
HTML Syntax
syntax.html
<div onwheel="handler">
Modern equivalent: el.addEventListener("wheel", handler). Use { passive: true } unless you must call preventDefault().
Values
Attribute Values
The value is a script (event handler code). Useful WheelEvent fields:
Use this unless you intentionally override default behavior.
Edge Cases & Pitfalls
Most mistakes mix up wheel with scroll, or block scrolling for performance and accessibility.
scroll
Do not use delta* as scroll direction
MDN: detect scrollTop / scrollLeft changes in scroll instead.
passive
Canceling wheel can hurt scroll performance
Prefer { passive: true }. Only use passive: false when you must preventDefault().
legacy
Avoid onmousewheel
Deprecated non-standard predecessor. Use wheel / onwheel.
touch
No wheel on many phones
Provide buttons, pinch, or other controls — do not rely on wheel alone.
a11y
Do not trap scrolling without a plan
Blocking wheel for custom zoom can confuse keyboard and assistive users. Offer alternatives.
Compatibility
Browser Support
onwheel is an HTML event attribute for the standard wheel event. It is not a Node.js, Deno, or Bun API.
✓ Widely available on desktop
onwheel
Supported in modern desktop browsers. Mousewheel is obsolete. Touch-first devices may never fire wheel — design a fallback.
96%Global support (approx.)
Google ChromeYes
Full support
Mozilla FirefoxYes
Full support
Apple SafariYes
Full support
Microsoft EdgeYes
Full support
OperaYes
Full support
Samsung InternetYes
Full support
Internet Explorer9+
Supported
onwheelWidely supported
Bottom line: Safe to use for desktop wheel/trackpad gestures. Pair with scroll listeners for position, and never depend on wheel alone for mobile.
Remember
Key Takeaways
Role: react to mouse wheel / trackpad wheel input.
Not scroll — use onscroll for position changes.
Prefer{ passive: true } unless canceling.
Skip deprecated onmousewheel.
One line:onwheel reports wheel/trackpad gestures — not the same as scrolling, and not a substitute for mobile touch UX.
Frequently Asked Questions
It is an event handler for the wheel event. It runs when the user rotates a mouse wheel or performs a similar trackpad gesture over the element.
wheel is input (device rotation). scroll means the scroll position changed. Wheel can fire without scrolling; scrolling can happen without a wheel (keyboard, scrollbar, script).
WheelEvent properties for vertical and horizontal wheel deltas. Signs and units vary by device and deltaMode — do not treat them as the scroll direction of the page.
No. mousewheel is a non-standard deprecated predecessor. Use the standard wheel event / onwheel instead.
Wheel handlers that may call preventDefault can delay scrolling. addEventListener("wheel", handler, { passive: true }) tells the browser you will not cancel, which helps performance. Use passive: false only when you must preventDefault (for example custom zoom).
No. wheel is the modern replacement for mousewheel. Support is broad on desktop; treat touch-first UIs carefully because there is no wheel hardware.