MDN may have intermittent access issues April 18 13:00 - April 19 01:00 UTC. See whistlepig.mozilla.org for all notifications.

mozilla
Your Search Results

    Window.devicePixelRatio

    The Window.devicePixelRatio read-only property returns the ratio of the (vertical) size of one physical pixel on the current display device to the size of one CSS pixel. Note that as the page is zoomed in the number of device pixels that one CSS pixel covers increases, and therefore the value of devicePixelRatio will also increase.

    There are no callbacks or events to listen to when this value changes (for example, if you drag the window between displays with different densities).

    Syntax

    value = window.devicePixelRatio;
    

    Example

     

    Specification

    CSSOM View Module

    Browser compatibility

     

    See also

    Document Tags and Contributors

    Contributors to this page: Sole, fscholz, Jonathan_Watt, teoli
    Last updated by: fscholz,
    Hide Sidebar