From the course: Sass Essential Training

Unlock the full course today

Join today to access over 24,100 courses taught by industry experts.

Parent selector

Parent selector

“

- [Instructor] The parent selector lets you easily work with nested styles to choose the parent of a current class. It's a brilliant idea. Let's take a look at how that works. So to specify that you're asking for the parent, you use the ampersand symbol. You can see it right here where I'm inside this button class and I'm targeting the hover state of that button class to make the button have a different background color whenever I roll over it. Basically what this does is create a style that targets the parent and then adds whatever is to the right of this. And it's going to copy the code from the parent and insert it in this new style. That means that I can also use it to create a suffix. So you can create a class called dot btn dash primary by using the ampersand right here. I could even specify that I want to create another class that has a prefix before it. So in this case I would be looking for a button class…

Contents