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

SERGIO RODRIGUEZ
SERGIO RODRIGUEZ
17,532 Points

box-sizing: box-border; as default way of sizing boxes.

I think that the way of sizing a box when the ''CSS box-border: box-border'' property is declared is much more intuitive than the regular CSS2.1 box model.

Is there any way to make this the default way of sizing boxes for a project without having to write this line of code each time I am sizing a box?

Are there any drawbacks from using this box-border sizing method as the default way of sizing? (e.g things start to render in the wrong way?)

Lush Sleutsky
Lush Sleutsky
14,044 Points

You mean the box-sizing property?

.something {
    box-sizing: border-box / content-box / padding-box
}

It is very handy, but there are times when it won't be needed, or can't be used optimally, so it will never be default. You could however, just set that property via a universal selector when you are making your stylesheet...

* {
    box-sizing: border-box / content-box / padding-box
}

I do that quite often. But a property like that cannot be default, because pages styled with CSS can be done easily without it. Hope that helps...

1 Answer

James Barnett
James Barnett
39,199 Points

You can use this at the top of all of your stylesheets.

* {
    box-sizing: border-box;
}
SERGIO RODRIGUEZ
SERGIO RODRIGUEZ
17,532 Points

Thanks!!

Will this have any "negative" effect on how the page is rendered?