This page is Almost Ready

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.



Retrieves the device’s horizontal Dots Per Inch (DPI) value.

Property of css/cssom/screencss/cssom/screen


var result = element.deviceXDPI;
element.deviceXDPI = value;


The following examples use the deviceXDPI property to retrieve the horizontal DPI of the screen. The function in this example returns 1 if Internet Explorer is not adjusting the scale of the screen.

  function fnScaleFactorX() {
    var nScaleFactor = screen.deviceXDPI / screen.logicalXDPI;
    return nScaleFactor;

This example uses the -ms-zoom property of the BODY element to adjust the scale of the page “manually” if Internet Explorer is not adjusting the scale of the screen and the user’s horizontal DPI is higher than normal. This is a simple but imprecise way to make a document look the same on higher resolution screens. You can achieve finer control over the layout of your documents by modifying the properties of individual elements or groups of elements.

  // change layout on HighDPI screens when IE not scaling
  function fnScaleManually()
    // normal DPI
    var constNorm = 96;

    // scaling is off and DPI higher than normal
    if ((screen.deviceXDPI == screen.logicalXDPI)
      && (screen.deviceXDPI > constNorm))
    { =
        constNorm / screen.logicalXDPI;



On most systems, there is no difference between horizontal and vertical DPI. The deviceXDPI property was introduced in Microsoft Internet Explorer 6. For information about how Internet Explorer 6 and later can adjust the scale of the display on screens with higher-than-normal DPI, see Adjusting Scale for Higher DPI Screens.


Standards information

There are no standards that apply here.

See also

Related articles


Related pages

  • screenscreen
  • Reference
  • deviceYDPI
  • logicalXDPI
  • logicalYDPI