DEV Community

Discussion on: You Probably Don't Need Media Queries Anymore

Collapse
 
ortonomy profile image
🅖🅡🅔🅖🅞🅡🅨 🅞🅡🅣🅞🅝 • Edited

Nice article - clamp is the single biggest tool to use in the box here. I find working with grids a pain in the butt, compared to flex.

However...

This is not against you, so please don't take it as a personal criticism. Because everyone makes this mistake. But people who write about CSS really gotta stop writing this nonsense about EMs and REMs.

EMs are a nightmare to work with specifically because they are a proportion of their parent element and in the simple example, it's too much to really have to comprehend when writing clean styles

<div style="font-size: 20px;">
  <div style="font-size: 50%;">
    <div style="font-size: 200%">
       <p>bizarrely, I'm 20px in size</p>
    </div>
  </div>
</div>
Enter fullscreen mode Exit fullscreen mode

So you revert to REM? But REM is literally bound to a root value, (usually 16px as default, commonly reset to 10px by :root { font-size: 62.5% }.)

This nonsense about 'herp, derp, are you still using pixel sizes' -- well, newsflash, using REM is just the same as using an explicty pixel size as far as I can tell. You just write it in a different format.

The REAL reason for using REM is to tie to your measurements to a single base size in a way that means a change to the root size would cause your UI to scale nicely in a proportional way.

Collapse
 
ludanjubara profile image
LudaNjubara

I would like to hint you that making your font-size explicitly with 'px' values and not say REMs or EMs would make your user's browser typography preference overruled. Meaning that there would be no scaling of your font-sizes if the user chose to do so in the browser settings. So, it's always better to use resizible units like REMs unless you want something to have the same font size no matter the user's preference.

Collapse
 
ortonomy profile image
Comment marked as low quality/non-constructive by the community. View Code of Conduct
🅖🅡🅔🅖🅞🅡🅨 🅞🅡🅣🅞🅝

What did you not get about:

The REAL reason for using REM is to tie to your measurements to a single base size in a way that means a change to the root size would cause your UI to scale nicely in a proportional way.

EMs are just recipes for disaster.

Thread Thread
 
ludanjubara profile image
LudaNjubara

Your original comment makes little sense to me then. Why make an obvious point about the difference between EM and REM when the author quite literraly stated the fact that EMs should generally be avoided and REMs should be used instead. You then go on about saying REMs and PX values are just the same..when in reality they aren't, simply 'couse of the fact that REMs are scalable and PX are not. They are only the same when looked at from coding perspective...not to the browser and users who alter their settings only to find out, to their dissapointment, that the UI hasn't changed. I'd kindly advise you to edit your comment accordingly and not to restate what author had already stated in the blog b'couse it leads to unnecessary confusion for the readers.
Ty and wish u successful coding. Sry for the long comment :/

Collapse
 
murkrage profile image
Mike Ekkel

This nonsense about 'herp, derp, are you still using pixel sizes' -- well, newsflash, using REM is just the same as using an explicty pixel size as far as I can tell. You just write it in a different format.

This is only true if you set the base value to be a pixel value. Ideally you wouldn’t touch it and allow the user to decide the base size. This is 16px by default but fully depends on the size of the text a user has selected.

This is great because larger text requires more whitespace, which is exactly why you would use REM for spacing as well because it scales with the font size of the user!

The mistake developers make is setting the base REM value to be a hardcoded value.

Some comments have been hidden by the post's author - find out more