3

By default, the computed dimensions are given in px in Chrome DevTools. Is it possible to have them displayed in mm instead?

(In case you are wondering why someone would want to do that, I need to generate HTML that will be converted to PDF for printing and ultimately I have to reason in mm to do that.)

Edit: To clarify my question I am not interested in the dimension on any device, just computed mm from the css which always is 96/25.4 px.

sunless
  • 597
  • 5
  • 19
  • 1
    Possible duplicate of [21680629](https://stackoverflow.com/questions/21680629/getting-the-physical-screen-dimensions-dpi-pixel-density-in-chrome-on-androi). – Andrzej Ziółek Jun 25 '18 at 16:12
  • 1
    In my case the maths is pretty obvious, it just boring to do myself: - 1mm is 96/25.4 px. And indeed Chrome computes correctly 566.9 px for 150 * (96/25.4) = approx 566.9 – sunless Jun 25 '18 at 16:29
  • But 1mm is 96/25.4px only for your screen, your resolution. – Andrzej Ziółek Jun 25 '18 at 17:10
  • Ok. But I am not interested in a value that would be true for all devices. Ultimately all I care is to be able to apply a linear function to the value. I was hoping that would be possible. – sunless Jun 25 '18 at 17:46
  • I'm tuning my page for printing and that would be a way to understand why things are overflowing despite a fixed height in mm... – Zied Hamdi Jun 21 '23 at 13:30

1 Answers1

0

You can't change the computed output. The reason the computed output exists, is to provide developers with the final information interpreted by the engine when all the calculations are done.

To improve your workflow, check out the snippets feature of the debugger. There you can write custom JS which is easy to re-execute and get whatever data you need out of the page regularly.

Garbee
  • 10,581
  • 5
  • 38
  • 41
  • 1
    One example of such a snippet might be: `console.log('snippet: clientWidth', $0.clientWidth, 'px', CSS.px($0.clientWidth).to('mm').value.toFixed(1), 'mm', $0);`. You might wrap above line in a function like `function mm() { ... }` then inspect any element with the mouse to have it in `$0` and type `mm()` in the console. – bartolom Apr 21 '19 at 11:18