News for hackers. Stuff that matters.
Re:Everything You Want to Know About Media Queries and Respo... by bruce343434 on Monday May 29, 2023 @05:51AM (#36112362)
Why is it not a thing to query the literal screen size in cm? Instead we have to work with fake pixel measures and scaling factors and a whole bunch of bullshit and edge cases.
Re:Everything You Want to Know About Media Queries and Respo... by dontlaugh on Monday May 29, 2023 @06:58AM (#36112728)
Or even more accurately, arcseconds at typical viewing distance. This would cover TVs and phones with the same measurement.
Re:Everything You Want to Know About Media Queries and Respo... by pjc50 on Monday May 29, 2023 @08:05AM (#36113130)
For desktop systems the EDID data is not always reliable. Besides, you don't want the screen size, you want the viewport size and the DPI.
Re:Everything You Want to Know About Media Queries and Respo... by bruce343434 on Monday May 29, 2023 @08:49AM (#36113431)
I think I want the arc length of the viewport. Fonts should have a minimum size based on that, certainly not 11pt or whatever.
Re:Everything You Want to Know About Media Queries and Respo... by Wowfunhappy on Monday May 29, 2023 @08:49AM (#36113436)
> Besides, you don't want the screen size, you want the viewport size and the DPI.

...I can think of at least one case where you really would want the screen size, although perhaps it's specialized enough to warrant a separate API.

As a user, I have often wished there was a reliable way to view an image on the web at "actual size". Examples would include purchasing band-aids on Amazon, or reading a Wikipedia article about insects. As far as I know, there's currently no good way for websites to offer this, and there really should be!

Re:Everything You Want to Know About Media Queries and Respo... by chrismorgan on Monday May 29, 2023 @08:58AM (#36113501)
Device diversity is such that that’s useless for general content. People use devices at less than arm’s length and at multiple metres away. Firefox used to have an experimental resolution-independent millimetre unit mozmm, but devices simply don’t tend to expose what you need so most of the time it wasn’t accurate. Browser makers considered standardising such a thing, but consensus was that (a) it wasn’t possible to make it accurate far too much of the time, and (b) it’s almost never what you want anyway (about the only legitimate uses: simulating a ruler, and physically-accurate sizing for comparison with physical artefacts; certainly never on general-purpose web pages), so it was just dropped.
Re:Everything You Want to Know About Media Queries and Respo... by kevincox on Monday May 29, 2023 @10:57AM (#36114627)
It's also worth noting that CSS "pixels" are not real pixels. There are somewhat scaled to the relative size. But even better you can set your breakpoints in terms of `rem` which is the user's default font size. This usually gives a pretty good intuition to how big UI components need to be to be easily readable to the user. This can also handle differences such as a user with great vision on a small device (they set a tiny font to get the most of the limited screen space) compared to a user with limited vision on a large screen far away (their text size may be cranked high so that they can see it).
Re:Everything You Want to Know About Media Queries and Respo... by zuprau on Monday May 29, 2023 @11:52AM (#36115095)
Seems logical, but as a user, I can already choose the size of the content of the screen, I don't want you to choose it for me. So we all agreed that "16px text" is ok and we started designing the world around that.

As a practical example: my iPhone lets me chose between "native" and "scaled up" sizing. This affects the whole OS including the browser. Where does your "cm" measurement fit in that? Do you want to override my (user) choice?

Additionally, every browser lets me scale the content up and down between 50% and 200%, so "cm" is broken once more.

"pixels" haven't been "pixels" for a very long time, and that's ok, they're now just a logical unit.