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 Foundations The Box Model Width, Height and Overflow Properties

Forcing padding to width of the box

The challenge is this

Currently, the width of the div with the class main is set to 400px, but the padding applied is adding an extra 40 pixels to its total width. Add a property that forces the padding into the width of the div.

however adding the property box-sizing: padding-box doesn't work and the answer it accepts is box-sizing: border-box

The accepted answer seems incorrect to me or am I misunderstanding?

3 Answers

James Barnett
James Barnett
39,199 Points

This question is oddly worded given the existence of padding-box. However since only Firefox supports padding-box in many cases it's existence is ignored.

further reading

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

@Griffin Byatt - Well border-box works and should be an acceptable answer, but based on the question border-padding should also work. Or is border-padding not an option in this workspace?

Griffin Byatt
Griffin Byatt
8,903 Points

The accepted answer is correct. Border-box and content-box are your options for box-sizing -- border-box takes border, padding, and content into account. It has a confusing name though.