Screen.pixelDepth is a read-only number for the screen’s bit depth (MDN). Read it as window.screen.pixelDepth. Per the CSSOM, some implementations return 24 for compatibility.
Read the notes below before you rely on this property. Prefer feature detection when support is limited.
Syntax
Use screen.pixelDepth. Start with this line.
JavaScript
screen.pixelDepth
Call
What it does
screen.pixelDepth
Primary signature.
Built into the browser. Read screen.pixelDepth on window.screen — no import required.
Library declarations
JavaScript
screen.pixelDepth
Parameters
This member has no parameters beyond those shown in the signature.
Use for diagnostics — not as a hard hardware fingerprint.
Prefer CSS for most visual adaptation; keep this as a simple check.
Compatibility
Browser Support
Screen.pixelDepth is Baseline Widely available (MDN: since July 2015). Remember: many engines report 24 for CSSOM compatibility rather than exact hardware depth.
✓ Baseline · Widely available
Screen.pixelDepth
Screen bit depth as a number — often 24 for compatibility across modern browsers.
98%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
pixelDepthExcellent
Bottom line: Safe to read everywhere. Do not treat the value as a precise hardware fingerprint — pair with colorDepth only for light diagnostics.
Frequently Asked Questions
A read-only number: the bit depth of the screen. Access it as window.screen.pixelDepth. Many browsers report 24 for CSSOM compatibility.
No. MDN marks Screen.pixelDepth as Baseline Widely available (since July 2015). It is not Deprecated, Experimental, or Non-standard.
MDN: per the CSSOM, some implementations return 24 for compatibility reasons. Check the compatibility table for engines that differ.
Both describe screen color capability. On most modern browsers they report the same number. Treat them as related diagnostics, not as a guarantee of exact hardware bit depth.
No. It is read-only. You read the number; you do not assign to it.
MDN shows that pattern to pick a richer vs simpler color. Today almost all user screens report at least 24, so the low-depth branch is rare—but it remains a clear teaching example.