Read local Y.offsetY is already relative to the control.
Divide by height.clientHeight is the inner height of the element.
Scale to 0–100. Multiply by 100 and clamp so edges stay in range.
Why it helps. The percentage still makes sense when the control resizes.
Compatibility
Browser Support
MouseEvent.offsetY is Baseline Widely available (MDN: since December 2015). It is not Deprecated, Experimental, or Non-standard.
✓ Baseline · Widely available
MouseEvent.offsetY
Element-local vertical pointer coordinate from the target’s padding edge — ideal for hit-testing and local drawing.
UniversalWidely available
Google ChromeAll versions · Desktop & Mobile
Full support
Mozilla FirefoxAll versions · Desktop & Mobile
Full support
Apple SafariAll versions · macOS & iOS
Full support
Microsoft EdgeAll versions · Chromium & Legacy
Full support
Internet ExplorerIE 6+ · Legacy environments
Full support
OperaAll modern versions
Full support
offsetYExcellent
Bottom line: Safe to use in modern browsers. Pair with offsetX for local 2D points, and use clientY/pageY when you need viewport or document space.
Frequently Asked Questions
It is a read-only number: the vertical offset of the mouse pointer from the padding edge of the event’s target element, measured in CSS pixels.
No. MDN marks MouseEvent.offsetY as Baseline Widely available (since December 2015). It is not Deprecated, Experimental, or Non-standard.
offsetY is measured from the top padding edge of the target node—inside the border, at the start of the padding box. Borders are outside that origin; padding and content are inside.
clientY is relative to the browser viewport. offsetY is relative to the element that received the event (event.target). The same spot on a moved element keeps a similar offsetY, while clientY changes with the window position.
pageY is relative to the whole document (includes vertical scroll). offsetY stays local to the target element’s padding box and does not grow just because the page scrolled.
A double (floating-point) number in pixels. Early versions of the spec defined it as an integer; modern browsers report a double.