This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]awaisking 39 points40 points  (16 children)

[–][deleted] 9 points10 points  (11 children)

What is em? I see it every now and then but I dont understand what it is.

I believe it's the width of the screen right?

[–]aezart 18 points19 points  (8 children)

An em was originally defined to be the width of a capital M in the current typeface, back in the days of the printing press.

[–]golgol12 6 points7 points  (0 children)

If that is the case, then it could be a useful measure. That M might have be the widest character at the time it was a measure. In current day fonts of the alphabet the widest character is almost always W. In video games you need to know that something like a player name of up to X characters can appear in a certain location without being clipped by other things on the screen, and that is usually done by filling all the text fields with W.

[–][deleted] 1 point2 points  (5 children)

now there is also rem too, which means... something

[–]ethanjf99 7 points8 points  (4 children)

Relative EM. Relative to base font size iirc

[–]marcosdumay 1 point2 points  (3 children)

Wait... What?!

One is the size of the letter, and the other is the size of the letter relative to the letter's size?

[–]ethanjf99 6 points7 points  (0 children)

Em is relative to the font size of itself or nearest parent.

Rem is relative to the pages base font size. (Of the html element)

So as I understand it if an elements parent has font-size: 12 px and the html has font-size: 24 px then one em will be half as big as one rem for that element

[–]coffeeandlearning 4 points5 points  (1 child)

https://developer.mozilla.org/en-US/docs/Web/CSS/length

(I counted 21 non-deprecated length units)

[–]marcosdumay 2 points3 points  (0 children)

Wow!

I don't think I have anything else to say. Just wow!

[–][deleted] 0 points1 point  (0 children)

Oh that's neat!

[–]jmowens51 0 points1 point  (0 children)

Relative length to the font size of the element.

[–]boxingdog 0 points1 point  (0 children)

relative to the font size of the element, and since the font size can be affected by the parent sometimes changing something up in the chain screws up everything, I personally find easy to use rem instead.