A pixel ruler measures distances on screen in pixels. It’s the fastest way to check whether a button really has 16 px padding, or whether two cards are 24 px apart. ruleronphone works as an online pixel ruler: switch the unit to px, then use paired guides or a selection box to measure pixels on screen. For exact values from a web page’s code, pair it with your browser’s DevTools.

CSS pixels, not device pixels

Always measure UI in CSS pixels. That’s the unit your design file, your CSS and your design tokens use. A phone with a device pixel ratio of 3 draws each CSS pixel with 3 × 3 physical pixels, but a 16 px margin is still 16 CSS pixels. More on this in CSS pixels vs device pixels.

ruleronphone measures in CSS pixels, so its readings match your code.

Platform Name for the CSS-like unit Relation
Web CSS pixel (px) Base unit
iOS Point (pt) 1 pt = 1 CSS px in Safari
Android Density-independent pixel (dp) 1 dp = 1 CSS px in Chrome
Figma, Sketch Pixel (at 1×) Same as CSS px

Which tool for which job?

You want to check… Best tool
Exact padding, margin, width of a web element DevTools (Method 3)
The gap between two elements, visually Paired guides (Method 1)
An icon, avatar or tap target’s size Selection box (Method 2)
A designer’s screenshot or mockup Screenshot method (Method 4)
Physical size on a real device Calibrate and switch to mm

How to put the ruler next to what you’re measuring

A web page can’t draw on top of other tabs or apps, so place the ruler beside the content:

  1. Open the ruler in its own browser window and set the unit to px.
  2. Make the ruler window narrow and snap it next to the window you’re checking (Win + ← / → on Windows; drag or use tiling on a Mac).
  3. Keep both windows at 100% zoom and on the same monitor. Then one ruler pixel is one CSS pixel in the other window.
  4. Line up the ruler’s guides with the edges you want to measure.

If the two windows are on different monitors, or one is zoomed, their pixels won’t match.

Method 1: Paired guides for gaps and spacing

Guides are the best tool for spacing: margins, gutters and the gap between two elements.

  1. Open the ruler and set the primary unit to px.
  2. Turn on Guides. Two lines appear.
  3. Drag the first guide to the edge of one element, and the second to the edge of the next.
  4. Read the distance between them. It updates live as you drag.

Because the guides stay where you put them, you can check the same spacing in several places, like every item in a list.

Method 2: Selection for element size

Use Select to measure an element’s width and height in one go.

  1. Switch to Select mode.
  2. Drag a box from one corner of the element to the opposite corner.
  3. Read width, height and diagonal in px, with a secondary unit if you like. Tap to copy the reading.

This is handy for icons, images, avatars and tap targets.

Tap target sizes

Guideline Minimum Unit
WCAG 2.2, 2.5.8 Target Size (Minimum), level AA 24 × 24 CSS px
WCAG 2.2, 2.5.5 Target Size (Enhanced), level AAA 44 × 44 CSS px
Apple Human Interface Guidelines 44 × 44 pt
Google Material Design 48 × 48 dp

WCAG’s 24 px minimum can also be met with spacing: a smaller target is allowed if a 24 px circle centered on it doesn’t overlap other targets. To know how big 44 px really is on your finger, calibrate the ruler and switch to mm: on an iPhone 15 it’s about 7.3 mm.

Method 3: Browser DevTools

For exact values from the code itself, DevTools is unbeatable.

  • Chrome / Edge: right-click → Inspect (or Ctrl + Shift + C / ⌘ + Shift + C) and hover an element. The overlay shows its size, padding (green) and margin (orange). The Computed tab lists every value.
  • Firefox: Inspect → Layout panel shows the box model. The built-in Measure a portion of the page tool (enable it in DevTools settings) draws a pixel ruler box.
  • Safari: enable Show features for web developers in Settings → Advanced, then Develop → Show Web Inspector.

Measuring the gap between two elements: DevTools shows each element’s own box, not the space between them. Add the first element’s bottom margin and the second’s top margin (minding margin collapse in normal flow), or check the gap value on a flex or grid container.

When to use an on screen ruler instead: for things that aren’t in the page’s code, like a static mockup image, a video frame or a designer’s export, or on a phone where DevTools isn’t available.

Method 4: Screenshots and mockups

Screenshots are in device pixels, so divide by the device pixel ratio:

Screenshot from Divide by 48 px in the screenshot is
Standard monitor (1×) 1 48 CSS px
Retina Mac, most iPhones (2× or 3×) 2 or 3 24 or 16 CSS px
Android phone (often 2.625–3.5×) Its DPR ≈ 14–18 CSS px

To measure a screenshot: open it in an image editor, or in a browser tab at 100%, and select the area. Or open it at “actual size” in an image viewer beside the ruler window. If the mockup was exported at 2× from Figma, divide by 2.

UI spacing checklist

Check Common values
Base spacing unit 4 px or 8 px grid
Spacing scale 4, 8, 12, 16, 24, 32, 48, 64
Body text size 16 px on the web (browser default)
Body text line height 1.4–1.6 × font size
Card padding 16–24 px
Section spacing 48–96 px
Minimum tap target 24 px (WCAG AA); 44–48 px recommended
Readable line length About 45–75 characters

If a measurement is off by 1 px, that’s usually sub-pixel rounding. Browsers lay out at fractional pixels and round when drawing.

Checking an 8-point grid: every spacing value you measure should divide evenly by 8 (or 4). A 20 px gap in an 8 px system is a sign of a hard-coded value.

Pixels and real-world size

Pixels are relative. A 100 px button might be 2.6 cm on a monitor and 0.6 cm on a phone. If you need the physical size, for print or for accessibility checks on a real device, calibrate the ruler and switch the unit to mm. See how to measure an image on screen and what is PPI.

100 CSS px on… Physical size
24” 1080p monitor (92 PPI, 1×) ≈ 27.6 mm
MacBook Air 13.6” (224 PPI, 2×) ≈ 22.7 mm
iPhone 15 (460 PPI, 3×) ≈ 16.6 mm

How many millimeters is one pixel?

There’s no single answer for screen pixels, because it depends on the display. CSS does define a nominal value: the CSS specification fixes 1 in = 96 px, so one CSS pixel is nominally 25.4 ÷ 96 = 0.2646 mm. That’s the size a pixel would be on a 96 PPI screen at 100% scaling, and it’s what browsers use for print. On real screens the physical size of a CSS pixel varies, as the table above shows.

Unit Nominal CSS size (1 in = 96 px)
1 px 0.2646 mm
1 mm 3.78 px
1 cm 37.8 px
1 in 96 px
1 pt (typographic, 1/72 in) 1.333 px

These are the right numbers for converting CSS units in code (for example, a 12pt font is 16 px). They’re the wrong numbers for working out how big something looks on your phone. For that, calibrate the ruler with a card on the calibration page and read mm directly.

Pixel ruler tools compared: browser, Chrome extension, Windows, Mac, Photoshop

Searches for a “chrome extension pixel ruler” or “pixel ruler Windows” usually come from people who want to measure across any app, not only inside a web page. Each option has a trade-off:

Tool Measures Install needed Works on phones
ruleronphone (this site) CSS px, plus mm/in after calibration No Yes
Browser DevTools Exact CSS box model of page elements No (built in) No (desktop only)
Chrome extension rulers Overlay on the current web page Yes No
Microsoft PowerToys Screen Ruler (Windows) Any app, in physical screen pixels Yes (free) No
macOS screenshot crosshair (⌘ + Shift + 4) Any app; shows coordinates while you drag No No
Photoshop, GIMP, Figma Pixels inside an image or design file Yes Partly

Windows: PowerToys Screen Ruler opens with Win + Shift + M by default and measures between edges anywhere on screen. It reads physical pixels, so on a display set to 150% scaling, divide its reading by 1.5 to get CSS pixels.

Mac: press ⌘ + Shift + 4, then drag. The numbers beside the crosshair show the size of the selection in points, which equal CSS pixels at default scaling. Press Esc to cancel without taking a screenshot.

Photoshop: turn on rulers with Ctrl/⌘ + R, set Preferences → Units & Rulers to pixels, and use the Ruler tool (in the eyedropper group, shortcut I). The options bar shows width (W), height (H) and length (L1). GIMP has a similar Measure tool (Shift + M). Figma: select a layer, hold Alt/Option and hover another layer to show the distance between them in red.

The advantage of a browser pixel ruler is that it runs on any device without installing anything, including a phone or tablet where none of the desktop tools exist.

How do I measure an image’s size in pixels?

There are two different questions here, and they need different tools.

  • The image file’s dimensions (for example 1920 × 1080): open the file’s properties (Windows: right-click → Properties → Details; Mac: Get Info or Preview → Tools → Show Inspector). No ruler needed.
  • A distance inside the image (the gap between two buttons in a mockup, the height of a logo): open the image at 100% (actual size) and measure with the selection box, or use an editor’s ruler tool. Remember to divide by the export scale: a 2× Figma export is twice the CSS size.

If an image is shown scaled on a web page, DevTools’ hover card shows both the rendered size and the intrinsic (file) size, for example “300 × 200 px (intrinsic: 1200 × 800 px)”.

Worked example: auditing a card component

Say a design spec calls for a card with 16 px padding, a 24 px gap between cards and a 44 px tall button.

  1. Open the page at 100% zoom and the ruler in a narrow window beside it, unit set to px.
  2. Put guide 1 on the card’s left border and guide 2 on the left edge of the text. Reading: 16 px. Correct.
  3. Move the guides to the right edge of card 1 and the left edge of card 2. Reading: 20 px. That’s off the 8 px grid, so inspect the container in DevTools: it’s set to gap: 20px instead of a 24 px token.
  4. Use Select on the button: 40 × 40 px. That passes WCAG 2.2 AA (24 px) but is under Apple’s 44 pt and Material’s 48 dp recommendations, so flag it.
  5. Copy each reading into the bug report with the expected value.

Checking three or four values like this takes a couple of minutes and catches most spacing drift.

Common mistakes when measuring pixels

  • Measuring at the wrong zoom. At 110% browser zoom, a 16 px gap shows as about 17.6 px on the ruler. Press Ctrl/⌘ + 0 in both windows.
  • Mixing monitors. A laptop at 2× and an external monitor at 1× have different pixel sizes. Keep the ruler and the content on the same screen.
  • Forgetting the device pixel ratio on screenshots. A phone screenshot shows a 16 px margin as 32, 48 or more pixels. Check window.devicePixelRatio in the console if you’re unsure.
  • Measuring to anti-aliased edges. Text and rounded corners have soft edges a pixel or two wide. Measure from the element’s box (DevTools) when it matters.
  • Assuming the box is the visible edge. Shadows, borders and transparent padding make an element look smaller or bigger than its box. Decide whether you’re measuring the box or what the eye sees.
  • Reading physical size from px. Pixels don’t map to millimeters until you calibrate.

Troubleshooting pixel readings

Problem Likely cause Fix
Every reading is about 10–25% too big Browser zoom or OS display scaling Reset zoom to 100%; measure with DevTools for exact CSS values
Reading is 1 px off DevTools Sub-pixel layout and rounding Trust the computed value in DevTools
Screenshot values are 2× or 3× too big Screenshot is in device pixels Divide by the device pixel ratio
PowerToys and the browser disagree PowerToys reads physical pixels Divide by the Windows scaling factor
Guides drift when the window resizes The content reflowed Measure after the layout settles at its final width

Sources

  • W3C, Web Content Accessibility Guidelines (WCAG) 2.2: Success Criteria 2.5.5 and 2.5.8.
  • Apple Human Interface Guidelines (hit targets); Google Material Design (touch targets).
  • W3C CSS Values and Units Module Level 3 (CSS pixel).
  • Chrome, Firefox and Safari DevTools documentation.