MouseEvent.y is a read-only number and an alias for clientY: vertical position inside the viewport. Learn why the short name exists, prove y === clientY, and practice with five try-it labs.
01
Kind
Instance property
02
Returns
Number (CSS px)
03
Status
Baseline Widely available
04
Alias of
clientY
05
Pair with
x / clientX
06
Origin
Viewport top edge
Fundamentals
Introduction
Some APIs like short names. event.y is simply another way to read the same viewport Y that event.clientY already gives you. Pair it with event.x (alias of clientX) for a compact viewport point.
JavaScript
document.addEventListener("mousemove", (event) => {
console.log(event.y); // same as event.clientY
console.log(event.clientY); // viewport Y in CSS pixels
});
💡
Beginner tip
MDN one-liner: MouseEvent.y is an alias for MouseEvent.clientY. If you already understand clientY, you already understand y.
Concept
Understanding the Property
MDN: the y property is an alias for clientY. That means it is the vertical coordinate within the application’s viewport at which the event occurred—not the document page and not the OS screen.
Instance — read event.y in a handler.
Number — CSS pixels from the viewport’s top edge.
Alias — same value as event.clientY.
Read-only — set via constructor options (usually clientY) on synthetic events.
Foundation
📝 Syntax
JavaScript
const y = mouseEvent.y;
Value
A number in CSS pixels from the top edge of the viewport—identical to mouseEvent.clientY on supporting browsers.
MouseEvent.y is Baseline Widely available across modern browsers (MDN: since April 2017). Logos use the shared browser-image-sprite.png sprite from this project.
✓ Baseline · Widely available
MouseEvent.y
Short alias for clientY—viewport Y in CSS pixels for mouse events.
UniversalWidely available
Google ChromeFull support · Desktop & Mobile
Full support
Mozilla FirefoxFull support · Desktop & Mobile
Full support
Apple SafariFull support · macOS & iOS
Full support
Microsoft EdgeFull support · Chromium
Full support
OperaFull support · Modern versions
Full support
Internet ExplorerSupported in modern IE versions
Full support
yExcellent
Bottom line: Read event.y or event.clientY for viewport Y; they are the same value on supporting browsers.
Wrap Up
Conclusion
event.y is the short name for viewport Y—an alias of clientY. Use either property for fixed UI and hit tests; reach for pageY when document scroll matters.
Use position: fixed overlays with viewport coordinates
Prefer one naming style in a codebase for consistency
Pass clientY in synthetic MouseEvent options
❌ Don’t
Assume y equals pageY after scrolling
Confuse viewport y with screen screenY
Mix y and clientY randomly in the same file
Use viewport coords for document-absolute markers
Mutate event.y on live user events
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about y
Short alias for clientY—viewport vertical position.
5
Core concepts
🖱️01
Instance
on the event
Kind
🔄02
Alias
of clientY
MDN
📐03
Viewport
top edge origin
Origin
🔢04
Number
CSS pixels
Type
🛡️05
Baseline
widely available
Status
❓ Frequently Asked Questions
It is a read-only number that is an alias for MouseEvent.clientY: the vertical mouse position in CSS pixels relative to the browser viewport (the visible window area).
No. MDN marks MouseEvent.y as Baseline Widely available (since April 2017). It is not Deprecated, Experimental, or Non-standard, so no status warning banner is needed.
Yes. MDN states that MouseEvent.y is an alias for MouseEvent.clientY. In supporting browsers, event.y === event.clientY for the same event.
Both work. Many tutorials and codebases prefer clientY because the name clearly says “client/viewport.” Use y when you want shorter property names or CSSOM View-style naming next to event.x.
y / clientY are viewport-relative and ignore document scroll. pageY is document-relative and grows when you scroll down.
Pass clientY in MouseEvent options (for example new MouseEvent("click", { clientX: 120, clientY: 40 })). Engines typically expose the same value on event.y as well.
Did you know?
Together, MouseEvent.x and MouseEvent.y give you a tidy { x, y } point in viewport space—the same idea as clientX / clientY, just with shorter CSSOM View names.