What is em?


#1


Replace this line with your code.


#2

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.


#3

@jacklearningcode,
Here some background info

CSS
http://stackoverflow.com/questions/2385829/what-is-the-difference-between-px-em-and-ex

HTML
http://stackoverflow.com/questions/4537327/what-is-the-difference-between-cite-em-and-i-tags-of-html


#4

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.


#5

Is em the relationship between rem and px?


#6

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.


#7

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