Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

CSS Sass Basics Write Smart and Efficient CSS with Sass Functions Review

Nour El-din El-helw
Nour El-din El-helw
8,241 Points

What is the value of 1em?

Given the following function:

@function get-em($px, $base-font: 16px) { @return ($px / $base-font) * 1em; }

h1 { font-size: get-em(72px); }

What font-size value will get-em() return?

Isn't 1em = the font size of the parent element? Here it doesn't tell me the value of '1em' so how should I answer this? Probably, there is something I'm missing so please help.

1 Answer

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! 1em can be interpreted in several ways. It will be the size of the parent element if the font-size of the parent element has been specified. However, if it hasn't been specified, it will be the default size of the browser which is quite often 16px. You can check out this MDN documentation.

But this challenge is actually more about dealing with optional arguments. You send in 72px, but you don't send in anything for the $base-font, so it automatically assigns 16 px there. 72 px divided by 16 px = 4.5. Then we take that and multiply it by 1em. Which equals 4.5em.

You don't really need to know what the size of the parent or the browser is here. Whatever they are, this will be 4.5 times larger.

Hope this helps! :sparkles: