Keith Wagner

CSS Nesting: Use With Caution

As codebases grow and blocks of CSS get unwieldy — making them more complicated — the nesting selector — & — becomes harder and harder to keep track of.

 

I know I’m not going to convert nesting fans today. What I hope to send you away with is at least a more cautious approach. Consider keeping your nesting shallow

This is generally my approach. Keep it simple for things like hover states and whatnot. Anything much more than 1-2 levels deep and it becomes unwieldy.