Okay, first off, yes I have read many many articles (Should I use px or rem value units in my CSS?) and forums about this.
I know that 1px is not a physical pixel but rather a CSS pixel, and rem
is basically the same as em
, but it is relative to the root element (hence the r in rem - root), rather than the parent element. em
itself is equal to the size set in the document, and it is popular due to the scalability in comparison with pixel, which cannot be scaled.
In all articles I read that everyone loves rem, and it should be used for font-size
in modern browser, but also use px
as a fall back for IE8 and lower. I see the main reason people use rem is so that the size scales better and is more "mobile friendly".
Now suddenly I read articles saying that all modern browsers support viewport
, so scalibilty is no longer that big of an issue.
Then I read to properly convert rem to px and vice versa, we can use html { font-size: 62.5%; }
which then turns 1rem to 10px.
So after all this confusion, if scalibilty is no issue because of viewports and 1rem is converted to 10px via html 62.5%, plus I will use pixels as a fall back anyway, then why use rem in the first place and not just stick with pixel? I don't see any advantages of using rem
anymore.
Or did I miss some major advantage of rem
?
html
is not even "right", because you're then assuming the browser's default font size is16px
, which are surely not guaranteed. Usingpx
andrem
are two different thing. The good thing ofrem
is that when the reader doesn't have a good eye, he/she can increase the base font size in browser and the whole document can be enlarged accordingly. That said, if some of your layout should stay in absolute value (e.g.padding: 10px
), just usepx
, don't reverse calculate it torem
. – Scherle