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) Basic Layout box-sizing and max-width

Adam Akers
Adam Akers
7,357 Points

Does box-sizing squeeze the content inside of the <div> to make up for the additional border and padding?

Does using the box-sizing rule squeeze or resize the content inside of the <div> to make up for the space used by the border and padding? I am just trying to make sense of what happens to these two values and rules when box-sizing is used.

1 Answer

Kevin Korte
Kevin Korte
28,149 Points

You are correct. The default value of content-box is specified width + padding + border + margin.

The common border-box is fits the padding and border inside of the specified width. Margin is still outside of this value.

There is also a padding-box value that is content +padding inside the width while border and margin are outside this width value.

https://developer.mozilla.org/en-US/docs/Web/CSS/box-sizing