HOME HTML CSS JAVASCRIPT SQL PHP JQUERY XML ASP.NET MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

Screen colorDepth Property

Screen Object Reference Screen Object

Example

Return the bit depth of the color palette:

var x = "Color Depth: " + screen.colorDepth;
document.getElementById("demo").innerHTML=x;

The result of x will be:


Try it yourself »

Definition and Usage

The colorDepth property returns the bit depth of the color palette for displaying images (in bits per pixel).


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The colorDepth property is supported in all major browsers.


Syntax

screen.colorDepth

Return Value

Type Description
Number The bit depth of the color palette for displaying images, in bits per pixel. Possible values:
  • 1 bit per pixel
  • 4 bits per pixel
  • 8 bits per pixel
  • 15 bits per pixel
  • 16 bits per pixel
  • 24 bits per pixel
  • 32 bits per pixel
  • 48 bits per pixel


More Examples

Example

Display an alternate background color for 8 bit screens (to avoid that 8 bit screens, which do not support the modern color, uses an ugly substitute color instead):

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

Try it yourself »

Example

A demonstration of all screen properties:

document.write(screen.width + "*" + screen.height);
document.write(screen.availWidth + "*" + screen.availHeight);
document.write(screen.colorDepth);
document.write(screen.pixelDepth);

Try it yourself »


Screen Object Reference Screen Object

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates

SHARE THIS PAGE