What is em?


Replace this line with your code.


em is short for emphasis. This makes the target text in italics.

But if you speak of STYLING, it is a unit of measurement like px for pixels.


Here some background info




I'm talking about CSS.

I'm on The CSS part of Make a Website part 7/10 and it says

em: A relative value that changes in proportion to the size of the parent element. For example, if a parent element has font-size: 20px;, child elements with font-size: 1em; would be equivalent to 20px. Child elements with font-size: 0.5em; would be equivalent to 10px (a halving) and so on.

I don't quite understand the example.


Is em the relationship between rem and px?


It means just exactly as stated.

Say I have:

.menu a {
	font-size: 1.2em;

What happens is that the parent element of a has a specified or maybe default font-size. a which is a child, is now told to have a font-size 1.2 times of the parent font-size.

rem has more relationship with px and then you can tie that up to em.

1 rem = 16 px

And so if I say a child element should have 2 em font-size, I have told it to have a font-size of 32px which then means 2rem.

I also recommend you read go into the links @leonhard.wettengmx.n posted.

If not sufficient, please revert.

Thank you.


This topic was automatically closed after 7 days. New replies are no longer allowed.