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

Kaycee Harris
Kaycee Harris
935 Points

Em, px, and %

When do i use the em unit and how to determine which parent element to divide by. Also when do i use percentages and pixels. Can I avoid using em if i wanted to? What is the difference between em and percentages. This lesson has me a bit confused, i understand the math but I don't understand how em's work

1 Answer

MDN:

... em units and percentages do the same thing for font-size.

  • Parent value is the first font-size rule up at DOM tree (in CSS code).
  • If it's not set or set as 100% or 1em, so it's usually 16px.
kevin pineda
kevin pineda
1,262 Points

nice answer, just have to keep it simple with too much explaining we can get confused in what terms are used for...