Menu

Browsers don't know how big your screen is: building an on-screen ring sizer
📰

Browsers don't know how big your screen is: building an on-screen ring sizer

DEV Community: astro·Kristal Thapa·10 days ago
#KSg3zy1n
#devtoastro#devto#dev#screen#const
Long article (1223 words) — no AI summary yet.
Reading 0:00
15s threshold

I built Check My Ring Size , a free tool where you hold a ring up to your screen and match it to a circle. It sounds like a weekend project. The hard part is one sentence: a web page has no way to ask how big a millimeter is.

If a circle is drawn 104 pixels wide, nothing in the browser tells you whether that is 17 mm on someone's phone or 30 mm on an old monitor. A ring that is 17.3 mm across (a US size 7) has to be drawn at exactly the right size, or the whole tool is worthless. This post is about how I solved that, and the bug that made my first version wrong by a factor of two to three.

Why CSS units don't help

CSS has mm and in, so it is tempting to write width: 17.3mm and move on. Don't. By definition, a CSS inch is 96 CSS pixels, and that is a reference value, not a measurement of your actual screen. On a real display, 17.3mm renders at whatever size the OS and panel happen to produce.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.