In a 2013 article, Peter-Paul Koch concluded that “screen.width/height is completely unreliable.” The main reason being that some browsers provide values in physical pixels, while others measure “the width and height of the ideal viewport; the one you get when using width=device-width.”
Which option is the preferred one? Is there an “official” definition? Currently there is no official definition, however there has been some past work which has aimed at providing a standard. The in CSSOM View Module, W3C Working Draft 17 December 2013 states:
The width attribute must return the width of the output device, in CSS pixels.
The height attribute must return the height of the output device, in CSS pixels.
In January 2015, we decided to Continue reading