CSS Sass Basics Write Smart and Efficient CSS with Sass Nesting Media Queries

Joe W
Joe W
Front End Web Development Techdegree Student 5,623 Points

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

1 Answer

Jamie Reardon
Jamie Reardon
Treehouse Project Reviewer

He 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).