13.7 The Screen Object
The colorDepth property specifies the base-2 logarithm of the number of colors that can be displayed. Often, this value is the same as the number of bits per pixel used by the display. For example, an 8-bit display can display 256 colors, and if all of these colors were available for use by the browser, the screen.colorDepth property would be 8. In some circumstances, however, the browser may restrict itself to a subset of the available colors, and you might find a screen.colorDepth value that is lower than the bits-per-pixel value of the screen. If you have several versions of an image that were defined using different numbers of colors, you can test this colorDepth property to decide which version to include in a document.
Example 13-4, later in this chapter, shows how the Screen object can be used.