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 trialJoseph Longo
1,074 PointsHelp: the everything element!?!?
I asked this question in a previous post, but I think if I ask this question here, I will be able to receive more clarity on this topic.
*, *:before, *:after { -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box; }
What does the above CSS mean/do, and when should I use it? I copied this code from the HTML forms wed design track. Basically, what does it do? Should I automatically just include this code in my CSS as good practice, EVEN IF I DO NOT understand it?
Thanks,
Joe
1 Answer
Nick Pfisterer
8,064 PointsThe * is known as the universal selector. Basically, it selects every element in your page. In this case, that box-sizing property is being applied to every element, as well as any :before or :after psuedo-elements, on the page.
This technique of setting the box-sizing property on every element to border-box is popular because it tells every element to include padding and borders in their defined width instead adding them to the width. This makes calculations a lot easier to handle since you can add padding and borders to an element without the width suddenly changing on you.
For further reading and even a more modern update on this technique, check out this great blog post by Paul Irish.