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

Why does the instructor constantly use em to set padding instead of px?

I noticed that many times when he set the padding he always went with em. e.g. padding-left: 1em;

why didn't he use px? Is there a reason for this?

I know px is an absolute unit of measurement, em is not an absolute unit. It is a unit that is relative to the currently chosen font size. but what's the reason to choose em over px in his cases. he didn't explain

px is an absolute unit of measurement, em is not an absolute unit. It is a unit that is relative to the currently chosen font size.

1 Answer

There isn’t really a specific reason why, to be honest. It’s just another way of doing it.