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


Ashley Keeling
Ashley Keeling
11,476 Points

em and rem

i know how to work out em and rem, but im not sure why you world use these insted of using px. also i dont get what the difference is between them. thanks

1 Answer

victor cooper
victor cooper
6,436 Points

em is a unit that is relative to the body font size, default is 16px. rem is a unit that is relative to it's parent, so if the <a> inside a <li> that has a font size of 20px will have a font size of rem it will be relative to 20px ( parent ) and not 16px ( body ).

i always use em for two reasons, i always set my main font size ones and from there i know my base, i dont have to alwasy think about the parent font size and his parent font size. set a main font size ones and work with it as needed. second reason is that em is a responsive unit and will look goo on all screen sizes without changes while with px you will need alot more media queries for the same result.

by law im required to use responsive font unit size for accessibility reasons, so em is the only unit i can use with accessibility tools that enlarge font size.