MouseEvent.screenX is a read-only number: the mouse’s horizontal position relative to the screen (monitor), not the page or the viewport. Learn how it differs from clientX and pageX, multi-monitor behavior, and five try-it labs.
01
Kind
Instance property
02
Returns
Number (CSS px)
03
Status
Baseline Widely available
04
Origin
Screen left edge
05
Pair with
screenY
06
Scroll
Does not affect screenX
Fundamentals
Introduction
Sometimes you care about where the pointer sits on the physical display—not where it is inside the scrolled page or the browser chrome. That is screenX (horizontal) and screenY (vertical): coordinates in screen space.
JavaScript
document.addEventListener("mousemove", (event) => {
console.log(event.screenX); // pixels from screen left
});
💡
Beginner tip
Move the browser window around your monitor: clientX stays tied to the window, while screenX tracks the pointer across the whole display.
Concept
Understanding the Property
MDN: screenX provides the horizontal coordinate (offset) of the mouse pointer in screen coordinates. In a multiscreen setup, horizontally aligned screens are treated as one device, so the range of screenX can span their combined width.
Instance — read event.screenX in a handler.
Number — CSS pixels; a floating-point double.
Screen-relative — independent of page scroll.
Read-only — set via constructor options on synthetic events only.
Foundation
📝 Syntax
JavaScript
const x = mouseEvent.screenX;
Value
A double floating-point value in pixels (MDN). Early versions of the specification defined this as an integer; modern engines expose a double for subpixel precision.
Mental model: use screenX for display-relative work, clientX for viewport UI, and pageX for document markers. Pair screenX with screenY for a full screen point.
Cheat Sheet
⚡ Quick Reference
Goal
Code
Read screen X
event.screenX
Screen point
{ x: event.screenX, y: event.screenY }
Compare systems
screenX / clientX / pageX
Route by bands
if (e.screenX < 50) …
MDN status
Baseline Widely available (Jul 2015)
Snapshot
🔍 At a Glance
Four facts about screenX.
Kind
instance
On the event
Type
double
CSS pixels
Origin
screen
Left edge = 0
Status
baseline
Widely available
Hands-On
Examples Gallery
Examples follow MDN MouseEvent.screenX. Move the mouse and (if you can) drag the browser window to see screen vs viewport values.
📚 Getting Started
Read screenX / screenY from live pointer events.
Example 1 — Log Screen and Client Coordinates
MDN-style demo: show screen and client positions on mousemove.
📤 Output (depends on where you click on the screen):
right band
How It Works
MDN’s routing example uses absolute screen bands. In real apps you usually prefer viewport or element coordinates; this still shows how screenX can drive simple branches.
With scrollX === 0, pageX and clientX often match, while screenX is usually larger because it includes the window’s offset on the monitor.
Example 5 — Estimate Window Left with screenX - clientX
Rough teaching math: screen minus viewport hints at the window’s left offset.
JavaScript
document.addEventListener("mousemove", (e) => {
// Approximate: how far the viewport is from the screen's left
const approxWindowLeft = e.screenX - e.clientX;
console.log(approxWindowLeft);
});
Dragging the window sideways changes screenX - clientX while keeping clientX stable for the same point inside the page. Real apps rarely need this; it is a clear way to feel the difference between the two systems.
Applications
🚀 Common Use Cases
Debugging pointer position relative to the physical display.
Teaching screen vs viewport vs document coordinate systems.
Simple screen-band routing demos (as on MDN).
Synthetic events in tests with known screenX / screenY.
Understanding multi-monitor horizontal ranges.
Under the Hood
🔧 How It Works
1
Pointer moves on the display
The OS knows the cursor position in screen pixels.
Input
2
Browser keeps screen coordinates
Also maps to viewport and document for clientX / pageX.
Mapping
3
MouseEvent stores screenX
Your listener reads the horizontal screen coordinate.
Event
4
✓
Use screen coordinates
Compare with clientX / pageX when teaching or debugging.
Important
📝 Notes
Baseline Widely available (MDN, since July 2015).
Not Deprecated, Experimental, or Non-standard — no status banner required.
Horizontally aligned multi-monitor setups can widen the screenX range.
Value type is a floating-point double in modern engines.
MouseEvent.screenX 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.screenX
Reliable screen-relative X for monitor-space pointer positions.
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
screenXExcellent
Bottom line: Read event.screenX for monitor-space horizontal position; pair with screenY for a full screen point.
Wrap Up
Conclusion
event.screenX gives you the horizontal mouse position relative to the screen. Use it when you need display space; reach for clientX for viewport UI and pageX for document markers.
Place absolute page markers with screen coordinates
Assume it equals offsetX inside an element
Mutate event.screenX on live user events
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about screenX
Screen-relative X that ignores page scroll.
5
Core concepts
🖱️01
Instance
on the event
Kind
🔢02
Double
CSS pixels
Type
🖥️03
Screen
left edge origin
Origin
📈04
Scroll-free
ignores page scroll
Behavior
🛡️05
Baseline
widely available
Status
❓ Frequently Asked Questions
It is a read-only number: the horizontal mouse position in CSS pixels relative to the left edge of the user’s screen (monitor), not the browser window or the document.
No. MDN marks MouseEvent.screenX as Baseline Widely available (since July 2015). It is not Deprecated, Experimental, or Non-standard, so no status warning banner is needed.
clientX is measured from the viewport’s left edge (the visible browser window). screenX is measured from the screen’s left edge. Moving or resizing the window changes how they relate.
pageX is relative to the document and includes horizontal scroll. screenX ignores page scroll and window position relative to the document—it is screen-space.
MDN: in a multiscreen environment, screens aligned horizontally are treated as one device, so screenX can grow across the combined width of those screens.
A double floating-point number of pixels. Early specs defined it as an integer; modern engines expose a double for subpixel precision.
Did you know?
MDN notes that on multi-monitor setups with screens lined up side by side, browsers treat them as one wide device—so screenX can keep climbing past a single monitor’s width as the pointer crosses into the next display.