- Nesting:
.anElement {
&_aBlock {
…
}
&_anotherBlock {
…
}
&_anotherBlockAgain {
&:hover {
…
}
}
}
- Limiting Nesting to Pseudo Elements:
.anElement {
…
}
.anElement_aBlock {
…
}
.anElement_anotherBlock {
…
}
.anElement_anotherBlockAgain {
&:hover {
…
}
}
My issue with
Nesting
is I find it harder to read, if it gets long, then you have to go back and forth to check you're in the right element, where as if you have it there, then you can see it straight away.It makes
&
a lot easier to understand as "ah, this is a pseudo element" rather than having to decipher if it's a nested block or a pseudo element.I think it helps with promoting over use of nesting which can cause CSS bloat.
It's one less process for a CSS processor to do, which with 2000+ partials in the current project I'm working on, will help compile times if it was used across the whole code base.