Discussion

What's the difference between CSS “em” and “rem”?

I've read this much about this:

1) Learning Web Design Book by Jennifer Niederst Robbins

1 rem= 1* browser's default font size

1 em= depends on the element type, for h1 it's something, for h2, it's sth else.

2) https://css-tricks.com/confused-rem-em/

>While em is relative to the font-size of its direct or nearest parent, rem is only relative to the html (root) font-size.

I get the rem part, but not the em part. What does it mean?

3) https://blog.logrocket.com/using-em-vs-rem-css/#:~:text=Let%27s%20get%20started!-,What%20are%20em%20and%20rem%20and%20why%20use%20them%3F,relative%20to%20a%20set%20value.

I've read this as well but since I'm only knowing html and starting to learn css, I could not get most of the things written there.

4) https://www.youtube.com/watch?v=tlRLEsZa89M

I watch this short video. It does makes things somewhat clear about "inherits from parent".

Anyway, I am eager to learn the crux of "em". Maybe with some code examples, or figures(if it's lying anywhere in internet)

2 points Hippoly 4 years ago 2 comments

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton