Easy Tutorial
❮ Dom Obj Anchor Prop Video Error ❯

Screen colorDepth Property


Definition and Usage

The colorDepth property returns the bit depth of the color palette for the target device or buffer.

Syntax


Browser Support

All major browsers support the colorDepth property.


Examples

Example 1

Return the bit depth of the color palette:

The output of the above example:

Example 2

Display alternating background colors on an 8-bit screen:

if (screen.colorDepth <= 8)
    // Simple blue background color for 8-bit screens
    document.body.style.background = "#0000FF"
else
    // Elegant blue background color for modern screens
    document.body.style.background = "#87CEFA"

More Examples

This example includes all screen properties


❮ Dom Obj Anchor Prop Video Error ❯