MouseEvent.clientY is a read-only number: the mouse’s vertical position inside the viewport. Learn how it differs from pageY and screenY, why vertical scroll does not change the top-edge rule, how it pairs with clientX, and five try-it labs.
01
Kind
Instance property
02
Returns
Number (CSS px)
03
Status
Baseline Widely available
04
Origin
Viewport top edge
05
Pair with
clientX
06
Scroll
Does not shift origin
Fundamentals
Introduction
Together with clientX, clientY answers “how far down is the pointer in the window?” Zero is the top of the visible viewport—not the top of a long scrolled document.
JavaScript
document.addEventListener("mousemove", (event) => {
console.log(event.clientY); // pixels from viewport top
});
💡
Beginner tip
Imagine a sticky ruler on the browser window. Zero is always the top edge of what you currently see—even after you scroll the page down.
Concept
Understanding the Property
MDN: clientY provides the vertical coordinate within the application’s viewport at which the event occurred (as opposed to the coordinate within the page). Clicking the top edge of the viewport always yields clientY of 0, even if the page is scrolled vertically.
Instance — read event.clientY in a handler.
Number — CSS pixels; often a floating-point double.
Viewport-relative — not document scroll, not the OS screen.
Read-only — set via constructor options on synthetic events only.
Foundation
📝 Syntax
JavaScript
const y = mouseEvent.clientY;
Value
A number (double) in CSS pixels from the top edge of the viewport.
Compare
⚖️ clientY vs Other Y Coordinates
Property
Measured from
Scroll effect
clientY
Viewport top
Origin stays fixed to the window
pageY
Document top
Grows when you scroll down
screenY
Screen (monitor) top
Independent of page scroll
offsetY
Target element padding edge
Local to the hit element
Pair clientY with clientX for a full viewport point. For document-relative placement on a tall page, prefer pageX / pageY.
Cheat Sheet
⚡ Quick Reference
Goal
Code
Read viewport Y
event.clientY
Viewport point
{ x: event.clientX, y: event.clientY }
Fixed UI at pointer
el.style.top = event.clientY + "px"
Synthetic click
new MouseEvent("click", { clientX: 100, clientY: 50 })
MDN status
Baseline Widely available (Jul 2015)
Snapshot
🔍 At a Glance
Four facts about clientY.
Kind
instance
On the event
Type
number
CSS pixels
Origin
viewport
Top edge = 0
Status
baseline
Widely available
Hands-On
Examples Gallery
Examples follow MDN MouseEvent.clientY. Move the mouse and compare vertical coordinate systems in the try-it labs.
clientY updates as the pointer moves down the window. screenY uses the whole monitor instead.
Example 2 — Top Edge Stays 0 After Scroll
MDN insight: viewport top is always client Y of zero.
JavaScript
// Tall page + vertical scroll — click near the top of the *window*
document.addEventListener("click", (e) => {
console.log("clientY:", e.clientY);
console.log("pageY:", e.pageY);
// Near viewport top: clientY ≈ 0 even if pageY is large after scrolling
});
MouseEvent.clientY is Baseline Widely available across modern browsers (MDN: since July 2015). Logos use the shared browser-image-sprite.png sprite from this project.
✓ Baseline · Widely available
MouseEvent.clientY
Vertical mouse position in viewport CSS pixels—pair with clientX for fixed UI that follows the pointer.
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
clientYExcellent
Bottom line: Read event.clientY for viewport Y; use pageY when you need document coordinates.
Wrap Up
Conclusion
event.clientY is the pointer’s Y inside the viewport. Use it with clientX for window-relative UI, and switch to pageY when the document scroll position matters.
Use clientY alone when layout is scrolled document space
Expect synthetic coords to move the real OS cursor
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about clientY
Viewport Y for every mouse event.
5
Core concepts
🖱️01
Instance
on the event
Kind
📐02
Viewport
not the page
Origin
🔢03
Number
CSS pixels
Type
⚖️04
≠ pageY
scroll differs
Compare
🛡️05
Baseline
widely available
Status
❓ Frequently Asked Questions
It is a read-only number: the vertical mouse position in CSS pixels relative to the browser viewport (the visible window area), not the full page document.
No. MDN marks MouseEvent.clientY as Baseline Widely available (since July 2015). It is not Deprecated, Experimental, or Non-standard, so no status warning banner is needed.
clientY is measured from the top edge of the viewport and ignores page scroll. pageY is measured from the top of the document and grows when you scroll down.
screenY is relative to the entire screen (monitor). clientY is relative to the browser viewport only.
Because the viewport’s top edge is always Y = 0 for client coordinates. Scrolling the document does not move that edge, so clientY stays based on what you see in the window.
Pass clientY (and usually clientX) in MouseEvent options, for example new MouseEvent("click", { clientX: 120, clientY: 40 }).
Did you know?
MDN’s quick test for clientY mirrors clientX: click the top edge of the browser window and you get 0 whether or not the page is scrolled vertically. That is the fastest way to remember viewport vs page Y.