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
Eduardo Vargas
5,871 PointsAny downsides to using the universal selector with Border-Box rule?
Are there any downsides to applying "border-box" on everything using the universal selector? Is this a common practice in web development?
2 Answers
Jason Anello
Courses Plus Student 94,610 PointsHi Eduardo,
Some developers like to use it to make calculations easier when sizing boxes.
The older way of doing it was to use the universal selector to set border-box on all elements.
* {
box-sizing: border-box;
}
A current best practice is to set border-box on the html element only and let the rest of the elements inherit it from their parent.
Like this
html {
box-sizing: border-box;
}
*, *:before, *:after {
box-sizing: inherit;
}
This css tricks article can fill you in on the details of why it's better to do it that way.
https://css-tricks.com/inheriting-box-sizing-probably-slightly-better-best-practice/
Let me know if there's anything you don't understand.
Alexander Davison
65,469 PointsI don't think it is common...