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) The Box Model Padding

Kathya Sarria
Kathya Sarria
945 Points

Logic of the percentage used on the padding based on the width

I did not quite understand the padding based on the width. What is the width of that div? Can you go further in this logic? Thanks!

3 Answers

Jamie Reardon
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Jamie Reardon
Treehouse Project Reviewer

Percentages are a relative unit of measurement, they are always relative to something else. The parent containing element. Divs are a block level element, meaning they take up an entire line of content. Therefore the wildlife div without adding a width property, will take up 100% of the parent element (primary-content in this case). Padding percentages relate to that width value of the wildlife div.

Konrad Dziekonski
Konrad Dziekonski
7,798 Points

and where is specified the width of the container <div> element? because its shorter than the width of the screen, and even the header. Thanks!

Jamie Reardon
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Jamie Reardon
Treehouse Project Reviewer

The answer is mentioned in my original post. Nevertheless, by default, the div element is a block-level element which therefore takes the full width of the containing element. Which means, 100%.

Konrad Dziekonski
Konrad Dziekonski
7,798 Points

i think i posted it before the video explaining the box model, I get it now, thanks!