Screen.pixelDepth
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.
Syntax
let depth = window.screen.pixelDepth
Example
// if there is not adequate bit depth // choose a simpler color if ( window.screen.pixelDepth > 8 ) { document.style.color = "#FAEBD7"; } else { document.style.color = "#FFFFFF"; }
Specifications
Specification |
---|
CSSOM View Module (CSSOM View) # dom-screen-pixeldepth |
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 |
1
Starting with version 59 this property is no longer required to always return 24.
|
12 |
1 |
9 |
≤12.1 |
1 |
1
Starting with version 59 this property is no longer required to always return 24.
|
18
Starting with version 59 this property is no longer required to always return 24.
|
4 |
≤12.1 |
1 |
1.0
Starting with Samsung Internet 7.0 this property is no longer required to always return 24.
|
See also
© 2005–2021 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