As I’m learning to use Sass I decided to jot down some of the basics for reference. Most of this is coming from Hampton Catlin’s Sass Basics course on Treehouse (referral).
Nesting Selectors
The selectors can be nested for ease of writing and reading. This can help organize code in a way that like selectors are together. It also keeps us from having to repeat strings of selectors. A quick example would be:
Sass:
CSS Output:
You can even go deeper if you would like. Let’s take a look at 4 levels deep (the suggested maximum depth for Sass).
Sass:
CSS Output:
Using the & Symbol
There is a helper character that makes referencing parent selectors much easier. This character is the ampersand (&) symbol.