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

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
STAFF
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 ^_^