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 trialJoe W
Front End Web Development Techdegree Student 5,623 PointsAdvantages to nesting media queries in sass?
Can someone explain the advantage to nesting media queries like Guil does? Sure, it looks easier for a developer to read, but it seems to be more typing. Also, the output looks far more messy.
2 Answers
Jamie Reardon
Treehouse Project ReviewerHe is showing you how you can nest rules within rules. Why do this? Because you type far less repetition in your code by not having to repeat typing the same class, thus using one rule for the selector.
So it isn't more typing like you said, imagine saving the typing for longer selector names than the example in the video.
The output isn't going to matter, when you are going to compile/code it though sass anyway. Furthermore, you want to limit the level you nest selectors (no more than 2 levels if that).
mdmaleksharafali
2,392 PointsThe correct answer should be: Nesting keeps media queries local to the component and the original styles we are modifying.