Search code examples
csscss-selectorscompass-sasssass

Duplication in css selectors, SCSS


Let's say I have such style definitions:

.a.b   { ... }
.a.b.c { ... }

Is there a way to avoid .a.b part duplication using SASS/SCSS?


Solution

  • Nest the .a.b.c rule within .a.b and replace the first part with the & combinator:

    .a.b {
        ...
        &.c { ... }
    }