How to get actual screen size

Hi, I need to know how to get the actual screen size in points or centimeters, not in pixels. The javascript functions give me the pixels, but I need to know how many points or centimeters that is regardless if it comes from a browser or a device like an ipad or iphone.
Does anyone know the code to calculate this?
thank you,

Get out your tape measure and measure the screen yourself. There is no way that the operating system running on the computer can tell what the physical screen dimensions are and so no way for any program running on that operating system to be able to tell what the screen dimensions are and if the browser has no way of knowing because the operating system doesn’t know then something running in the browser (eg. JavaScript) also has no way to find out.

First, make sure you are talking about SCREEN resolution and not the pixels inside your WINDOW.

Either way, you will need to detect the resolution first, which you can do in most browsers using screen.width and screen.height.

Detecting WINDOW width, height gets a little trickier, thanks mostly to IE.
Good reference here if you need it: [URL=“”]

However, as felgall was pointing out, you cannot determine the value without knowing the dimensions of the output device, be it the monitor, a printer, or other device.

The general formula for pixels to centimeters is (Pixels / DPI) * 2.54

Here’s more info:…kb;en-us;127152

But there is no way of telling what the real DPI being used is. The operating system uses a nominal value that is not necessarily close to the real figure.

you can use this to get the pixels per inch on your screen

on my pc the alert() says my ppi = 96 which is what my system info says as well.

  1. create a div

  2. set the width to 1in

  3. output the div’s offsetWidth

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
<html xmlns="">
<style type="text/css">
#myDiv {
width: 1in;
<script type="text/javascript">
window.onload=function() {
<div id="myDiv"></div>

but when I divide 1280px wide screen by 96 I get only 13.33in :bawling:

That’s because the screen isn’t really using 96 dpi.

The other thing to remember is that the screen size is usually given as a single figure measured on the diagonal. You can work out the width and height from the screen size based on whether the screen is 3x4 or 9x16 (which is obvious when you look at the screen).

yep, I’m finding that out right now :slight_smile:

I put a 1 px red border on the div (so I can see where it is) and putting my ruler up to it, it is physically 29mm wide and the 1px border on each side is at best 0.5mm wide (but probably less) on each side.

so even taking away the width of the 1px border the div is still at least 28mm wide.

interesting :scratch: