nested - Should I always nest selectors in other selectors when using sass? -


my question nesting in sass or scss. thing readability perspective can nest selectors inside selectors in sass must do? little bit confused because when run scss-lint, i'm getting errors nesting depth. red few articles , know should go deeper nesting more 3 rules 1 inside another.

so have 2 questions:

  1. is there wrong if write rules in sass (without nesting):

    .my-class ...

instead of writing that:

header     nav         .myclass 
  1. can explain why necessary nest in sass , advantages of nesting? know overriding rules, if don't need nest deep? appreciate answers or links articles explaining questions in more detail.

you should avoid nesting selectors in sass if don't have reason to. see avoid nested selectors more modular css , beware of selector nesting in sass why should more selective nesting.

regarding formatting, you're doing functionally equivalent nesting, shouldn't formatting line breaks , indentations mimic nesting when that's not intent is.

header   nav     .myclass {...} 

and

header {   nav {     .myclass {...}   } } 

both produce:

header nav .myclass {...} 

so though scss-lint might getting tripped formatting, it's probably not want doing anyway. , if aren't concerned nesting or selector depth, disable or override linters.


Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -