There's more...
We can see that Sass nesting can go many levels deep, but just like many powerful features, it can be taken too far. Deeply nested selectors can cause problems, as they become difficult to read and potentially too specific for its context. Although many developers disagree on how many layers of nesting are too many, the general rule of thumb is using no more than 3-4 layers, depending on the application's styling complexity. Luckily, in Angular, we have other tools available to assist with limiting selector specificity besides Sass nesting, such as component styles.
When deciding whether to nest a selector in Sass or not, it may be worth checking the specificity needed to apply the selector. In cases where there isn't much ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access