W3cubDocs

/Web APIs

Screen: pixelDepth property

Returns the bit depth of the screen. Per the CSSOM, some implementations return 24 for compatibility reasons. See the browser compatibility section for those that don't.

Value

A number.

Examples

js

// if there is not adequate bit depth
// choose a simpler color
document.style.color = window.screen.pixelDepth > 8 ? "#FAEBD7" : "#FFFFFF";

Specifications

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari WebView Android Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet
pixelDepth
1Starting with version 59 this property is no longer required to always return 24.
12 1 9 ≤12.1 1
4.4Starting with version 59 this property is no longer required to always return 24.
18Starting with version 59 this property is no longer required to always return 24.
4 ≤12.1 1
1.0Starting with Samsung Internet 7.0 this property is no longer required to always return 24.

See also

© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/Screen/pixelDepth