Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

General Discussion

Context of padding !

Hello ,

I am not sure , but is that correct that when we want to calculate a fluid -padding- the context will be its width ! not the parent width -if has parent - !!

Because margin use the parent width for sure as a context .

3 Answers

Guil Hernandez
Guil Hernandez
Treehouse Teacher

You are correct, Omar.

The context for % is the width of the content area.

The context for ems is the font-size of the element.

One way to think of this might be to consider the CSS box model.

Padding adds space inside the box, so it's context is within the box also.

Margin adds space around (or outside) the box, so the context is the next box up (parent).

@guil Thank you so much for answering :)

@keithwyland Great idea to keep in mind , thank you ^_^