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 trialnicolasdeknoop
6,943 PointsHello there, just a quick question, why the universal selector * {box-sizing: border-box}? Thanks in advance!
i thought that basically universal selectors should be avoided due to their over-reaching power. (Perhaps in context, some developers not in favour of a hard-reset - margin:0; padding: 0;). Is this necessary for working with flexbox?
4 Answers
Josh Alling
17,172 PointsYou don't have to avoid using the universal selector completely, but it should only be used when you want every single element on the page to have the same attribute. In this case, you are giving every element the border-box attribute to make sure that all borders fit within the width and height of their elements.
Hope this helps.
Gabriel Roczanski
Courses Plus Student 2,136 PointsP.S, sorry my bad english.
Box-sizing will assists in edge and margin accounts, in which case it is applied makes all the tags. It won't reset, just set that all your tags will have the box-sizing: border-box.
nicolasdeknoop
6,943 PointsThanks Gabriel
nicolasdeknoop
6,943 PointsThought this may be of interest regarding universal selector usage over and above box-sizing (and hard-reset) ----- transitions, non-repeating backgrounds, relative positioning, and middle-alignment:
http://css-tricks.com/things-it-might-be-funuseful-to-try-the-universal-selector-on/
Kevin Korte
28,149 PointsI immediately thought of this article reading this: http://www.paulirish.com/2012/box-sizing-border-box-ftw/
If you haven't you should, it's short.
nicolasdeknoop
6,943 PointsThanks Kevin, I'll check it out!
nicolasdeknoop
6,943 Pointsnicolasdeknoop
6,943 PointsThanks Josh