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 trialSERGIO RODRIGUEZ
17,532 Pointsbox-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?)
1 Answer
James Barnett
39,199 PointsYou can use this at the top of all of your stylesheets.
* {
box-sizing: border-box;
}
SERGIO RODRIGUEZ
17,532 PointsThanks!!
Will this have any "negative" effect on how the page is rendered?
Lush Sleutsky
14,044 PointsLush Sleutsky
14,044 PointsYou mean the box-sizing property?
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...
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...