Pixel Ruler

Drag to measure any region in pixels. Width, height and diagonal in CSS pixels, plus device pixels and viewport percentages. No calibration needed.

Pixel measuring surface

Width

…

Height

…

Diagonal

…

Device pixels · share of viewport

…

Drag anywhere on the surface to measure a region. With it focused, the ← → keys resize the selection by 1 px, or 10 px with Shift held. Rulers along the top and left edge are marked in CSS pixels. Double-click to drop a guide line for checking alignment.

 

Measuring in pixels, exactly

This is the one tool on the site that needs no calibration, and the reason is worth understanding. Every other tile converts pixels into physical units, and that conversion depends on knowing your display's real pixel density. A pixel ruler skips the conversion altogether. It measures pixels in pixels, so the answer is exact on any screen, at any density, with nothing to set up first.

The rulers along the top and left edges are graduated every 10 px with labels every 100, and a selection extends guide lines into both gutters so you can read a span directly off the scale. There are four ways to work with it:

CSS pixels, device pixels, and why both matter

A CSS pixel is a layout unit, not a physical dot. On a standard display the two coincide. On any high-density screen a single CSS pixel gets painted using several device pixels, four at 2× and nine at 3×. The device pixel ratio is the number connecting them, and it appears beneath the surface for whatever display you are reading this on.

For front-end work the consequence is simple enough: you lay out in CSS pixels and export raster assets at the device-pixel size. An icon occupying 24 CSS pixels needs 48 px of real image data to look sharp on a 2× display, which is the whole reason srcset and @2x assets exist. Both figures sit side by side here so you are not doing that multiplication in your head.

The viewport percentages serve a related purpose. When you are converting a fixed-width mockup into responsive CSS, knowing an element is 20% of the viewport width is more directly useful than knowing it is 240 px, because it translates straight into vw and vh.

What a browser-based pixel ruler cannot do

It can only measure inside its own page. A web page cannot see other windows, other tabs or your desktop. That isolation is a deliberate and important security boundary rather than a limitation to route around. Measuring a native application's interface, or anything else outside the browser, calls for a desktop screen-ruler app with the right system permissions.

Within those bounds this is exact. For physical units instead of pixels, the online ruler converts using your screen calibration, and the screen size checker reports resolution, pixel ratio and density together in one place. The reason that conversion needs a calibration step at all, rather than a fixed formula, is explained in why two on-screen rulers never agree.

What a pixel ruler gets used for

Almost always the same handful of jobs, and all of them are comparisons rather than absolute measurements:

Why zoom changes the answer

Browser zoom does not magnify the finished page like a lens. It changes what a CSS pixel is worth, and the page is then laid out again at the new size. At 125 % zoom one CSS pixel is painted with 1.25 device pixels, so this surface still reports honest CSS pixels while everything on screen is physically larger.

That is the right behaviour, because CSS pixels are the unit you write styles in. It does mean that if you are comparing a measurement against a design file, both should be at 100 %. Ctrl+0 resets it, or Cmd+0 on a Mac. The device pixel ratio shown beneath the surface moves when you zoom, which makes it a quick way to check whether you are at 100 without hunting through a menu.

Guides, the crosshair and the keyboard

A double-click drops a dashed guide wherever you click, and guides stay put while you drag a selection around them, which is what makes checking alignment across a wide area practical. The crosshair reports live coordinates, useful when you want a position rather than a distance.

The keyboard is the part people miss. Focus the surface and the arrow keys resize the selection a pixel at a time, or ten at a time with Shift held. Dragging with a mouse is fine for getting close; the arrows are how you land on an exact figure, and they do not slip at the last moment the way a trackpad does.

Frequently Asked Questions

What is device pixel ratio?
The number of physical pixels your screen uses to draw one CSS pixel. At a ratio of 2, a 200-pixel button in your CSS occupies 400 physical pixels. It is the single most common reason two people measuring the same element disagree while both being right.
What is the difference between CSS pixels and device pixels?
A CSS pixel is the unit your stylesheet talks in. A device pixel is a physical dot on the panel. On an ordinary monitor they are the same thing; on a high-density screen one CSS pixel covers two or three device pixels in each direction. This ruler measures in CSS pixels, which is what you want when writing CSS.
How do I measure pixels on screen?
Drag across the area you want. The readout gives width, height and the diagonal in CSS pixels, and repeats it in device pixels so you can see both numbers at once.
Why does the measurement change when I zoom?
Because browser zoom changes how many device pixels go into a CSS pixel. At 125 % zoom every CSS pixel is drawn 25 % larger. Reset with Ctrl+0, or Cmd+0 on a Mac, before measuring anything you intend to write down.
Can I measure something outside the browser?
No. A web page cannot see beyond its own tab, which is a security boundary rather than a missing feature. For anything outside the browser, take a screenshot and measure that, remembering the capture is in device pixels.
Why is my screenshot twice the size I measured?
Because screenshots are captured in device pixels. On a screen with a device pixel ratio of 2, a 200-pixel element arrives in the file as 400 pixels. Divide by the ratio shown on this page to get back to CSS pixels.
What is the percentage of viewport for?
Responsive work. A box that is 640 px wide is meaningless on its own; that it is 50 % of the viewport is the thing you can act on when writing a breakpoint.
Can I use the keyboard?
Yes. Arrow keys nudge the selection a pixel at a time and Shift with an arrow moves it ten, which is more precise than a mouse for the last few pixels.