DEV Community

Discussion on: What CSS font-size units do you prefer to use?

Collapse
 
andrewbaisden profile image
Andrew Baisden

If you use rem for the fonts, margins, paddings and borders. Then if a user was to change the font size setting for their browser then, the whole page should scale uniformly without breaking.

Thread Thread
 
rtivital profile image
Vitaly Rtishchev

Have you tried changing font size in browser yourself? Do you test it before pushing to production (as font size changing can break some interface elements that were designed with identified sizes)?

From the user side this is also not a good idea, almost all users that need to scale will use browser scaling (cmd/ctrl + +) that will scale interface with all that?

Thread Thread
 
andrewbaisden profile image
Andrew Baisden

Yes I have tried changing it myself in fact I just did a test now on some websites to see what the result would be. It seems to work fine. No I don't really test for that prior to production because as you put it the average user is not going to be technical enough to play around with their browser settings like that they would just scale the browser.

I also just tried scaling some websites that use rem my portfolio included and it appears to work the design did not break apart.

Thread Thread
 
rtivital profile image
Vitaly Rtishchev

Well, then you can safely migrate to px πŸ˜„ as rem has no effect and px is much clearer

Thread Thread
 
andrewbaisden profile image
Andrew Baisden • Edited

Take a look at the post by Minh Nguyen on here and also this Pixels vs. Relative Units in CSS: why it’s still a big deal It makes a difference 😊

Thread Thread
 
rtivital profile image
Vitaly Rtishchev

Yep, I get that rem units have purpose, still I think that if you intent to support rem as a feature on your website then it's your responsibility to test out how it performs with scaled fonts – providing broken ui is worse than providing small ui that can be upscaled.

Thread Thread
 
andrewbaisden profile image
Andrew Baisden

Testing has always been a part of my development process its to be expected when you are building a website. Working with pixels is exactly the same it is not limited to rem. Some developers prefer rem whereas some prefer pixels as you can see from this discussion. Thats the great thing about being a developer the freedom of choice. πŸ™‚

Thread Thread
 
93alan profile image
Alan Montgomery

I back you Andrew, I use rem for everything. Fonts, margins, padding, width, height. Scales better with respnsiveness