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 Unused CSS Stages Flexbox and Multi-Column Layout Flexbox: Part 1

Hello 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
Josh Alling
17,172 Points

You 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.

Thanks Josh

P.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.

Thanks Gabriel

Thought 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
Kevin Korte
28,148 Points

I 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.

Thanks Kevin, I'll check it out!