Why an on-screen ruler has to be calibrated
A pixel is not a length. When CSS says an element is 96 pixels wide, that is a reference measurement defined against an assumed 96 pixels per inch, and almost no real display is 96 pixels per inch. A 24 inch 1080p monitor is about 92. A 27 inch 4K monitor is about 163. A modern phone is often above 400. Drawing a "one inch" line at 96 CSS pixels therefore produces a line that is one inch on nearly nothing.
The browser cannot tell you the real number. It exposes the viewport in CSS pixels and a device pixel ratio, and neither carries the physical size of the panel. Screen dimensions in millimetres are not available to a web page, deliberately: the exact display geometry is a fingerprinting signal, and browsers have been closing those channels rather than opening them. So a page that claims to draw a real ruler without asking you anything is guessing, and the guess is wrong by up to 70 percent between common displays.
The way out is to calibrate against an object whose size is fixed by international standard and which nearly everyone has. A bank card is exactly that. ISO/IEC 7810 ID-1 specifies 85.60 by 53.98 millimetres, and it governs every credit card, debit card and most national identity cards worldwide. You hold one against the screen, resize the outline until it matches, and that gives the one number the browser could not supply: how many pixels your display puts in a millimetre.
From that single ratio everything else follows, and it is worth saving, because it is a property of the display rather than of the session. The calibration is stored on your device so the ruler is correct the next time you open it, and the value never leaves the browser, which matters given that it is precisely the kind of display fingerprint the platform declines to hand out.
Two caveats, because they are the usual sources of error. Browser zoom changes the CSS pixel to physical pixel relationship, so a ruler calibrated at 100 percent zoom is wrong at 110 and you should recalibrate rather than compensate. And an external monitor is a different display: calibration follows the screen, not the computer.