Browse By Name
HTMLCSSJavaScriptAppendix
You are here: Reference > JavaScript > client-side > browser > properties > pixelDepth (screen)

pixelDepth property (screen)

A A Font size Print Content Add new content Share
Browser support:
Retrieves the number of bits used to represent the color of a single pixel on the screen or in the buffer when off-screen buffering is allowed.
The colorDepth property is identical to the pixelDepth property in Firefox, Opera and Safari, and it is supported by Internet Explorer. Use that instead.

Syntax:

object.pixelDepth;
You can find the related objects in the Supported by objects section below.
This property is read-only.

Possible values:

Integer that sets or retrieves the number of bits.
One of the following values:
1
1 bit per pixel.
4
4 bits per pixel.
8
8 bits per pixel.
15
15 bits per pixel. Same as 16 but only 15 bits are used.
16
16 bits per pixel.
24
24 bits per pixel.
32
32 bits per pixel.
48
48 bits per pixel.
Default: this property has no default value.

Example HTML code 1:

This example illustrates the use of the pixelDepth property:
<head>
    <script type="text/javascript">
        function GetPixelDep () {
            if (screen.pixelDepth === undefined) {
                alert ("Pixel Depth: " + screen.colorDepth);
            }
            else {
                alert ("Pixel Depth: " + screen.pixelDepth);
            }
        }
    </script>
</head>
<body>
    <button onclick="GetPixelDep (event);">Get the pixel depth!</button>
</body>
Did you find this example helpful? yes no

Supported by objects:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content