The parent selector, written as &, is one of the most powerful nesting tools in Sass. This lesson goes deep into how & works: combining with pseudo-classes, building BEM-style class names, and advanced placement within compound selectors.
What Does & Represent?
Inside a nested rule, & refers to the full selector of its enclosing rule. It lets you combine, extend, or reposition that selector without retyping it, which is essential for pseudo-classes, modifiers, and BEM-style naming.
.btn {
&:hover {
opacity: 0.9;
}
}
Compiles to .btn:hover { opacity: 0.9; }, & is replaced directly with .btn, no space added.
& immediately followed by a pseudo-class or extra class compiles with no space, producing a compound selector.
& can be part of a larger string, common for BEM elements (&__title) and modifiers (&--active).
& can appear on the right side of another selector to reference an ancestor context (.dark &).
Multiple & symbols can appear in the same selector for advanced combinator patterns.
Parent Selector Cheatsheet
The most common ways & is used in real SCSS.
SCSS
Compiles To
&:hover
.btn:hover
&.is-active
.btn.is-active
&__icon
.btn__icon
&--large
.btn--large
& + &
.btn + .btn
.dark &
.dark .btn
&, &:visited
.btn, .btn:visited
BEM Class Names With &
Combining & with string suffixes is the standard way to write BEM (Block Element Modifier) class names in Sass without repeating the block name for every element and modifier.
Compiles to .card, .card__title, .card__body, and .card--highlighted, four flat, non-nested CSS rules.
Referencing Ancestor Context
& isn't limited to the left side of a compound selector. Placing it on the right of another selector lets a component adjust its own styles based on an ancestor context, like a dark-mode wrapper class.
Compiles to .dark-mode .card { ... }, the component reacts to being inside .dark-mode anywhere above it.
Multiple Ampersands and Combinators
& can be combined with itself for patterns like styling adjacent siblings of the same component, useful for adding spacing between repeated items without a wrapping container.
.tag {
& + & {
margin-left: 0.5rem;
}
}
Compiles to .tag + .tag { margin-left: 0.5rem; }, spacing between two tags placed next to each other.
Common Mistakes
Adding a space between & and a suffix meant to be a compound selector, & .icon and &.icon compile to very different, unrelated selectors.
Overusing BEM modifiers nested many levels deep instead of keeping the block/element/modifier structure flat.
Forgetting that & inside a comma-separated selector list refers to the entire compound selector, not just one part of it.
Using & for unrelated selector patterns where a plain, explicit selector would be clearer to read.
Key Takeaways
& represents the enclosing selector and can be combined with pseudo-classes, extra classes, or string suffixes.
BEM elements and modifiers are commonly written as &__element and &--modifier.
& can also appear on the right of another selector to reference ancestor context, like a dark-mode wrapper.
& + & is a useful pattern for spacing between repeated sibling components.
Pro Tip
Combine & with BEM naming as your default nesting strategy, it gives you organized, readable SCSS while keeping the compiled CSS selectors flat and easy to override, unlike deep descendant nesting.
You now understand the parent selector & in depth. Next, explore Sass selector functions for inspecting and manipulating selectors programmatically.