W3cubDocs

/Web APIs

Screen: colorDepth property

The Screen.colorDepth read-only property returns the color 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

// Check the color depth of the screen
if (window.screen.colorDepth < 8) {
  // Use low-color version of page
} else {
  // Use regular, colorful page
}

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
colorDepth
1Starting with version 59 this property is no longer required to always return 24.
12 1 4 ≤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/colorDepth