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.

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!