English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Screen colorDepth Property

JavaScript Screen Object

colorDepthA read-only property that returns the color depth of the screen.

colorDepth is used to represent the number of bits used to represent the color of a single pixel.

colorDepth indicates how many colors the device screen can produce.

For example, the color depth is8The screen can produce256Colors (2 8)

Syntax:

screen.colorDepth
var x = "Color Depth: " + screen.colorDepth;
Test and see‹/›

Browser compatibility

All browsers fully support the colorDepth property:

Property
colorDepthIsIsIsIsIs

Technical details

Return value:A number representing the bit depth of the palette used to display the image, per pixel.
Possible values:
  • Each pixel1Bit

  • Each pixel4Bit

  • Each pixel8Bit

  • Each pixel15Bit

  • Each pixel16Bit

  • Each pixel24Bit

  • Each pixel32Bit

  • Each pixel48Bit

More Examples

This example displays all screen properties:

var txt = "";
txt += "<p>Total width/height: " + screen.width + "*" + screen.height + "</p>";
txt += "<p>Available width/height: " + screen.availWidth + "*" + screen.availHeight +"</p>";
txt += "<p>Color depth: " + screen.colorDepth + "</p>";
txt += "<p>Color resolution: " + screen.pixelDepth + "</p>";
document.write(txt);
Test and see‹/›

Related References

screen reference:screen.availHeight property

screen reference:screen.availWidth property

screen reference:screen.height property

screen reference:screen.width property

screen reference:screen.pixelDepth property

JavaScript Screen Object