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 CSS Basics (2014) Understanding Values and Units Em Units

Jamie Reardon
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Jamie Reardon
Treehouse Project Reviewer

Calculating em values

Do most or all of you know exactly what em size to use without using calculators for desired pixel font-sizes conversions to ems? Just wondering as I know my maths sucks and others are far more intellectual.

1 Answer

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,858 Points

Hi Jamie Reardon

I don't do much CSS, but I'm thinking a calculator will probably be very handy if you're converting your px to em units. Some may be straightforward, but some could get very complex, especially since CSS doesn't like you to round off the numbers. So if you had the parent being 16px, and you wanted one of your sub-headers or paragraphs to be the equivalent of 18.25px... well the em unit would be 1.140625. Unless one is a math prodigy... I'm going to say one is going to be using a calculator.

Just a note -- I have seen some em units have as much as 15 or more decimal places.

I'm sure once you do many sites, you will just know what size you're looking for. But, in the beginning, there would be no shame in using a calculator. :)

:dizzy:

Jamie Reardon
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Jamie Reardon
Treehouse Project Reviewer

I see thanks, haha I know there is some crazy mathematicians out there but was also thinking that it must be impossible to come up with all the divisions and so on. Thanks for the answer!