The read-only clientX property is the horizontal coordinate (CSS pixels) where the mouse event occurred, measured from the left edge of the viewport (visible window) — not the full page (MDN). Pair it with clientY for the vertical position.
Read the notes below before you rely on this property. Prefer feature detection when support is limited.
Syntax
Use event.clientX. Start with this line.
JavaScript
event.clientX
Call
What it does
event.clientX
Primary signature.
Built into the browser. Read event.clientX on a MouseEvent — no import required.
Library declarations
JavaScript
event.clientX
Parameters
This member has no parameters beyond those shown in the signature.
Set clientY too when handlers expect a full point.
Compatibility
Browser Support
MouseEvent.clientX is marked Baseline Widely available on MDN (since July 2015).
✓ Baseline · Widely available
MouseEvent.clientX
Viewport-relative X in CSS pixels. Pair with clientY. Safe everyday DOM API.
100%Widely 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
clientXExcellent
Bottom line: Safe everyday API. Viewport left edge → 0. See the MDN clientX reference.
Frequently Asked Questions
It is a read-only number: the horizontal mouse position in CSS pixels relative to the browser viewport (the visible window area), not the full page document.
No. MDN marks MouseEvent.clientX as Baseline Widely available (since July 2015). It is not Deprecated, Experimental, or Non-standard.
clientX is measured from the left edge of the viewport and ignores page scroll. pageX is measured from the left edge of the document and grows when you scroll right.
screenX is relative to the entire screen (monitor). clientX is relative to the browser viewport only.
Because the viewport’s left edge is always X = 0 for client coordinates. Scrolling the document does not move that edge, so clientX stays based on what you see in the window.
Pass clientX (and usually clientY) in MouseEvent options, for example new MouseEvent("click", { clientX: 120, clientY: 40 }).