DEV Community

Discussion on: Using REM Doesn't Make Your Website Responsive - Here's Why

Collapse
 
devdufutur profile image
Rudy Nappée

That's what happens when we use PX for font sizes: we ignore user preferences and impose the exact size we've chosen.

🤔🧐

Actually all modern browsers handle adapting font size in px according to user preferences...

px css unit doesn't actually rely on screen pixels but reference pixels, equivalent to 1/96 inches, meaning dependent to the density of screen in dpi but also the zoom level of the browser.

I don't really see a good reason using rem instead of px excepts increasing difficulty of code.

Collapse
 
marcelluscaio profile image
Caio Marcellus Cabral

Sorry, but that is not the case.

They do scale font with zoom, but if you set your font to pixels they are not going to adapt it to the user's font preferences.

So, you should not set your font size in pixels.

And I know it takes a while to adapt to writing in REM, but you eventually get used to it =)

And yeah, pixel actual size varies from device to device, due to screen density.

Collapse
 
devdufutur profile image
Rudy Nappée

What difference do you make between browser zoom and user preference ? Can you provide an example ? Thanks

Thread Thread
 
marcelluscaio profile image
Caio Marcellus Cabral

Changing the default size is like this: chromestory.com/2022/09/change-tex...

On the other hand, when you zoom in, browser adapts content, unless it is related to viewport size.

Again, using REM is not outdated in any way.

Thread Thread
 
devdufutur profile image
Rudy Nappée

Thanks for the precision, didn't knew this feature.

Collapse
 
stefanjudis profile image
Stefan Judis

Actually all modern browsers handle adapting font size in px according to user preferences...

I don't think that's true. I just tested Chrome and Firefox and neither adapt rendered font size defined in px to font default settings. Appearance -> Font size: very large (Chrome) or General -> Fonts -> Font size (Firefox) don't affect font sizes when they are defined in Pixels. Percentages or rem on the other hand do respect the default font size.

Image description

Collapse
 
devdufutur profile image
Rudy Nappée • Edited

Indeed my mistake. As mentionned in my reply to @marcelluscaio I was refering to zoom level, I didn't knew this font size setting.

Collapse
 
marcelluscaio profile image
Caio Marcellus Cabral

Great demo, Stefan! Interesting to notice that in font-sizes the percentage unit refers to the default font-size, so 100% is equivalent to 1rem