News for hackers. Stuff that matters.
Re:PX or REM in CSS? Just Use REM by Etheryte on Saturday December 03, 2022 @04:16PM (#33847441)
I'm not buying the font size argument at all. When you zoom in or out on a webpage, your base font size isn't changed, the whole page is zoomed instead, making this whole discussion moot. I would wager many (most?) nontechnical users don't even know they can change the base font size.
Re:PX or REM in CSS? Just Use REM by ehutch79 on Saturday December 03, 2022 @04:51PM (#33847791)
It's not zooming (ctrl +), it's when you literally set the font size in the browser. This is typically done for people with vision issues, or assistive technology
Re:PX or REM in CSS? Just Use REM by chrisweekly on Saturday December 03, 2022 @05:10PM (#33847951)
Something like 10% of people change their browser's default font size - a larger userbase than that of many browsers deemed worthy of support.
Re:PX or REM in CSS? Just Use REM by IshKebab on Saturday December 03, 2022 @06:03PM (#33848405)
3% according to the first result I found, which sounds way more plausible.

https://css-tricks.com/users-do-change-font-size

I couldn't find stats on zoom but I'd guess far far more people use zoom than font size which makes sense because it works reliably and doesn't break site layouts.

Re:PX or REM in CSS? Just Use REM by croes on Saturday December 03, 2022 @06:21PM (#33848551)
Where is the disadvantage in supporting these 10% by using rem instead of px?
Re:PX or REM in CSS? Just Use REM by chrisweekly on Saturday December 03, 2022 @06:59PM (#33848887)
Sorry I wasn't clearer! Use of rem is preferable to px because it supports this cohort of users who change their default font size. Using px ignores their preferences. There are other benefits to adopting a typographic scale as the basis for truly responsive design. See https://every-layout.dev for a masterclass in exposition of this idea.
Re:PX or REM in CSS? Just Use REM by lelandfe on Sunday December 04, 2022 @03:30PM (#33857529)
> There are other benefits to adopting a typographic scale as the basis for truly responsive design

Can you give some examples? I was of the belief that there weren't other benefits.

Nb I also dislike sources that use block and inline box model properties. It is a fictitious need: when will you ever add traditional Asian writing to your site?

Re:PX or REM in CSS? Just Use REM by martyfmelb on Sunday December 04, 2022 @07:37AM (#33853126)
Increased UI testing surface, tracing responsibility when things go wrong, and inserting a new decision for every single metric any FE developer ever writes.

- The more obscure combinations of viewing options you support, the more likely you'll miss some weird combination in your VRT or manual testing until an actual user in production finds it for you.

- But maybe your manual tester or VRT has excellent coverage. Still, it got more expensive. Supporting just one more text zoom level doubles your VRT expense. Your team has finite QA resources and VRT compute. Scope/quality/cost/time of something, somewhere, had to be dropped. Generally, is it worth it?

- If you are supporting REM and your designers don't distinguish between REM and PX, you have created new states that designers haven't planned for. You introduced a new cross-cutting source of design bugs, but if your designers didn't ask for this feature, they can't stem the flow of bugs!

- If you are supporting REM without coding guidelines to recommend what should be REM vs. what should be PX -- sans a hero dev who sees the impending mess and writes those docs for you -- you will get a chaotic and inconsistent mix of REMs and PX in your code.

Re:PX or REM in CSS? Just Use REM by lelandfe on Saturday December 03, 2022 @08:14PM (#33849466)
It has been substantially below 2% in the tests I’ve done for various medium-sized business sites. We had to have serious discussions about the work involved to convert values between pixels and rems relative to the amount of people it serves. (Especially when browser-based scale zooms are totally sufficient)
Re:PX or REM in CSS? Just Use REM by Wowfunhappy on Saturday December 03, 2022 @05:57PM (#33848363)
Honest question: why do people increase the font size instead of just changing the default zoom level?

I feel that the latter creates a more consistent experience.

Re:PX or REM in CSS? Just Use REM by croes on Saturday December 03, 2022 @06:19PM (#33848537)
Maybe because they just want bigger text and not a bigger site.
Re:PX or REM in CSS? Just Use REM by csande17 on Saturday December 03, 2022 @09:05PM (#33849803)
Unfortunately, if web developers follow the advice from the article to use rem units everywhere, they'll get a bigger site.
Re:PX or REM in CSS? Just Use REM by ehutch79 on Sunday December 04, 2022 @10:28AM (#33854490)
You are correct!

REM for text, PX for layout

But if you're going to choose one, use rem with the body text-size hack.

Re:PX or REM in CSS? Just Use REM by nailer on Saturday December 03, 2022 @06:21PM (#33848553)
Because old web browsers didn't let people zoom properly. I think IE7 was one of the first.
Re:PX or REM in CSS? Just Use REM by Wowfunhappy on Saturday December 03, 2022 @07:01PM (#33848901)
Yeah, and that makes sense in 2010, but not in 2022.
Re:PX or REM in CSS? Just Use REM by lmm on Saturday December 03, 2022 @07:21PM (#33849055)
Maybe I want to keep seeing images at 1:1. Maybe the font sizes are bad. I remember the days when the user was supposed to be in control of how websites were styled.
Re:PX or REM in CSS? Just Use REM by ehutch79 on Saturday December 03, 2022 @09:03PM (#33849795)
Depending on your vision, you might be able to see a button is a button, but the font is just too small by a few pts. You don't need borders or whatever zoomed, just the font size bumped a bit.
Re:PX or REM in CSS? Just Use REM by layer8 on Sunday December 04, 2022 @12:20AM (#33850860)
Because they don’t want the layout to get bigger, but just the text size within the existing layout.
Re:PX or REM in CSS? Just Use REM by SebastianKra on Sunday December 04, 2022 @07:07AM (#33852932)
But then the articles recommendation doesn't make sense, because using rem for everything would also scale the layout.

I'd guess that you should always use pixels except for /(max-)?(width|height)/, because these are the only properties that may make assumptions about the size the content.

Re:PX or REM in CSS? Just Use REM by muspimerol on Saturday December 03, 2022 @05:41PM (#33848236)
Exactly, zooming and base font size are two fundamentally different things. Forcing users to zoom to get a legible text size is not an acceptable solution.
Re:PX or REM in CSS? Just Use REM by cuu508 on Saturday December 03, 2022 @05:57PM (#33848362)
Wouldn't users also want legible icons, pictures, margins, etc.?
Re:PX or REM in CSS? Just Use REM by Filligree on Saturday December 03, 2022 @06:55PM (#33848859)
Most pictures can be shrunk significantly and remain legible. They don't need to be zoomed in on.
Re:PX or REM in CSS? Just Use REM by layer8 on Sunday December 04, 2022 @12:24AM (#33850872)
It depends on the icons and pictures. With pixel-based graphics, you want to keep those 1:1 for crispness, and not get a blurry interpolation due to zooming, at least on lower-DPI screens.
Re:PX or REM in CSS? Just Use REM by muspimerol on Sunday December 04, 2022 @07:34AM (#33853105)
No, not really. The browser setting is for default _font_ size for a reason. People want legible text. Design elements like icons, pictures, margins are generally decorative and not functional. If a user wants to set a default _zoom_ level, then they can set that as well. As I said, these are two different things.
Re:PX or REM in CSS? Just Use REM by IshKebab on Saturday December 03, 2022 @05:59PM (#33848377)
Why not? If you have trouble reading text are you not also going to have trouble reading icons, pictures, etc. too?
Re:PX or REM in CSS? Just Use REM by layer8 on Sunday December 04, 2022 @12:26AM (#33850883)
It depends on the icons and pictures. With pixel-based graphics, you want to keep those 1:1 for crispness, and not get a blurry interpolation due to zooming, at least on lower-DPI screens. And the custom base font size may just be e.g. two pixels larger than the default for comfortable reading.
Re:PX or REM in CSS? Just Use REM by IshKebab on Sunday December 04, 2022 @05:07AM (#33852228)
That seems like a very weak reason. High DPI screens are common now, as is SVG. And slightly blurry pixels is hardly the end of the world is it?

If that's the only problem I'll stick with px.

Re:PX or REM in CSS? Just Use REM by layer8 on Sunday December 04, 2022 @09:38AM (#33854049)
Low-DPI screens (e.g. Full-HD) are common on desktop systems and laptops, and will remain so for the foreseeable future, due to their lower cost. Pixel-based icons look better on those than vector icons. “Slightly blurry” is the bane of the modern web on those displays. I’m just telling you there’s a reason why some people prefer increasing only the text size — it makes for a better UX.
Re:PX or REM in CSS? Just Use REM by muspimerol on Sunday December 04, 2022 @07:40AM (#33853146)
That's what the default zoom level is for. There are plenty of people who just need slightly larger text so they can read, but don't want to zoom in every element of the page. Why are you making assumptions about what users want instead of just supporting basic web browser defaults? It's really not that difficult to support.