Screen.width is a read-only instance property that returns the full width of the screen in CSS pixels. Learn how it differs from availWidth and innerWidth, why OS chrome can shrink available space, and MDN’s classic 1024×768 check—with five examples and try-it labs.
01
Kind
Read-only property
02
Returns
Number (CSS px)
03
Access
window.screen
04
Meaning
Full screen width
05
Twin
screen.height
06
Status
Baseline widely
Fundamentals
Introduction
The browser’s screen object describes the display behind your window. screen.width answers: “How wide is the whole screen, in CSS pixels?” That is the full horizontal size of the monitor (or the display associated with this window)—not how wide the current tab is.
Operating systems may keep a vertical strip for themselves (taskbars on the side, docks, and similar chrome). That is why availWidth can be smaller than width. MDN also pairs width with height for crude resolution checks such as “at least 1024×768.”
JavaScript
console.log(window.screen.width);
💡
Beginner tip
screen.width is about the monitor. For the visible page width inside the tab, use window.innerWidth instead. Prefer CSS media queries for most responsive layout.
Concept
Understanding the Property
MDN: the Screen.width read-only property returns the width of the screen in CSS pixels.
Instance — on the Screen object from window.screen.
Read-only — you cannot assign to width.
CSS pixels — same unit family as layout sizes (not always hardware pixels).
Full width — may be larger than availWidth when OS chrome is reserved.
Foundation
📝 Syntax
JavaScript
const w = window.screen.width;
// same as:
const w2 = screen.width;
Value
A number: the full screen width in CSS pixels. Compare it with window.screen.availWidth when you care about space left after OS chrome.
Compare
📈 width vs availWidth
Property
Meaning
screen.width
Full screen width in CSS pixels
screen.availWidth
Width available for web content (often minus OS chrome)
screen.height
Full screen height (vertical twin)
window.innerWidth
Viewport / layout viewport width of this window
📌
MDN note
Not all of the width from screen.width may be available to the window. When other widgets occupy space the window object cannot use, there is a difference between screen.width and screen.availWidth. See also screen.height.
Practice
🎨 MDN Minimum Resolution Check
MDN’s teaching example: a crude way to check that the screen is at least 1024×768 CSS pixels.
JavaScript
// Crude way to check that the screen is at least 1024x768
if (window.screen.width >= 1024 && window.screen.height >= 768) {
console.log("Resolution is 1024x768 or above");
} else {
console.log("Resolution is below 1024x768");
}
Useful for diagnostics and teaching. For responsive UI, prefer CSS @media queries rather than hard-coding JS resolution gates.
Cheat Sheet
⚡ Quick Reference
Goal
Code
Full screen width
screen.width
Available width
screen.availWidth
Reserved horizontal px
screen.width - screen.availWidth
MDN min size check
width >= 1024 && height >= 768
This tab’s width
window.innerWidth
MDN status
Baseline Widely available (Jul 2015)
Snapshot
🔍 At a Glance
Four facts about screen.width.
Kind
property
Read-only
Type
number
CSS pixels
Via
window.screen
Screen object
Status
baseline
Widely available
Hands-On
Examples Gallery
Examples follow MDN Screen.width. Numbers on your machine will differ by display and OS chrome.
📚 Getting Started
Read the full width and practice the MDN resolution check.
Screen.width 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
Screen.width
Full screen width in CSS pixels — often larger than availWidth when OS chrome is reserved.
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
Supported
widthExcellent
Bottom line: Use screen.width for full display width; use availWidth for available horizontal space; use innerWidth for this window’s viewport; prefer CSS media queries for layout.
Wrap Up
Conclusion
window.screen.width is the full horizontal size of the screen in CSS pixels—sometimes a bit more than availWidth when OS chrome is always visible. Use it for display metrics and comparisons, not as a substitute for viewport width or CSS layout.
Hard-code JS resolution gates for all layout decisions
Assume side taskbars always subtract the same number of pixels
Ignore availWidth when planning secondary window sizes
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about width
Full screen width in CSS pixels.
5
Core concepts
🖥️01
Read-only
on Screen
Kind
📈02
CSS pixels
full screen width
Value
≥03
≥ availWidth
may include chrome
Rule
📐04
Twin
screen.height
Pair
🎯05
Baseline
widely available
Status
❓ Frequently Asked Questions
A read-only number: the full width of the screen in CSS pixels. Access it as window.screen.width.
No. MDN marks Screen.width as Baseline Widely available (since July 2015). It is not Deprecated, Experimental, or Non-standard.
screen.width is the full screen width. availWidth is the space available for web content and is never larger—often smaller when OS chrome reserves horizontal space.
No. width is the monitor’s full width. innerWidth is this browser window’s viewport width and changes when you resize the tab.
No. It is read-only. You read the value; you do not assign to it.
Use screen.height for the full screen height in CSS pixels, the vertical twin of width.
Did you know?
Multi-monitor setups still expose a single window.screen for the display associated with the window. Moving a window to another monitor can change the reported width when that display has a different resolution.