DEV Community

[Comment from a deleted post]
 
gustvandewal profile image
Gust van de Wal

rem is based on CSS pixels.
in and cm are based on CSS pixels.

Only predefined layouts like flex and grid,
and relative stuff like vw and %,
give you ACTUAL screen dimension related layouts.

But that is besides the point, because the CSS pixel is an elegantly defined measurement that is human based.
What you call guessing, is a nicely consistent thing, that I always use for background patterns, translate()s, profile icons, shadows.

Hell, I don't even see a practical way of doing shadows other than with px or other px based measurements.

The base font-size is defined in px for a reason...

creativepro.com/rethinking-the-pix...

 
webbureaucrat profile image
webbureaucrat

I mean if by "based on" you mean that there is a constant relationship between the two, then no, that's not correct. That's just not what the spec says, and I can't imagine what other meaning of "based on" you have in mind.

 
optimisedu profile image
optimisedu

I think the word you two are looking for is pixel aspect ratios...

 
bobdotjs profile image
Bob Bass

I thoroughly enjoyed reading this thread

 
acode123 profile image
acode123

Me Too!

 
gustvandewal profile image
Gust van de Wal • Edited

You can't imagine that "based on humans" means anything else than "consistent across devices"?

You obviously haven't read the article I linked. Holy cow are you smug, man...

 
webbureaucrat profile image
webbureaucrat • Edited

But it's not even a fixed relationship within a device--it's just a default. I could browse page and rem would be 16px and then click through to a site where 1rem is 1vw.

And if you want to set a nicer tone you should start by not using the word "ACTUAL" in all caps.

 
gustvandewal profile image
Gust van de Wal

HAHAHA, that's funny. All caps is just a way to emphasize text, my dude...

Having said that. My point in these threads is that besides viewport units and percentages, everything boils down to CSS pixels.

What is my purpose in clarifying that to everyone here? It's that if you say you use "physical units" like cm or "text-based" ones like rem because "a px isn't a device pixel", then you are missing information.

Sure, you can set the root font-size to something viewport related and use rem from then on — you win 🎉
But wait... That is just using rem as a variable and does not mean that rem is inherently more "relative" than px. Not to the device pixel, that is.

My actual, underlying, point would be that you should just hold your devices next to each other and decide for yourself: like I said, font-size is based on px for a reason: we created the CSS pixel in a way that using it across devices gives good results.

For stuff like paddings and text-indent, I use rem/em.
Borders, fixed-height navbar, shadows, tiled background-size, translate() values, I use px. And there is absolutely nothing wrong with that.

How do you even create shadows without px if they shouldn't grow with font-size??

 
webbureaucrat profile image
webbureaucrat

There are lots of correct ways of emphasizing text in markdown. Caps means shouting. Laughing is all caps is obviously rude and I know you know this so you're getting blocked immediately.

(by the way: rem doesn't grow or shrink with font size. You're thinking of em. rem is guaranteed to be the same within a page.)