peteboere / css-crush

CSS preprocessor.
http://the-echoplex.net/csscrush
MIT License
537 stars 51 forks source link

Nested rules #17

Closed lencioni closed 12 years ago

lencioni commented 12 years ago

It would be really nice to be able to use nested rules. Do you plan on adding this feature to CSS Crush?

For example, instead of doing this:

.myClass {
  ...
}
.myClass .mySubClass {
  ...
}

You could do this:

.myClass {
  ...
  .mySubClass {
    ...
  }
}
peteboere commented 12 years ago

I've considered it before but I have a few fundamental problems with nested syntax (my opinions):

Pros: Write less with less duplication It's clever

Cons: Harder to scan read, and thus maintain Encourages the output of overly specific selector chains

Granted you write less with less repetition, however, I find the nested syntax much harder to read in real examples; the CSSWG editor draft examples on http://dev.w3.org/csswg/css3-hierarchies/ look pretty awful.

As for preprocessor implementations I've had to maintain written in LESS the nesting hierarchy can span a lot of lines and become difficult to scan read and see the selector/ruleset relationships.

So not a fan personally, though I understand the appeal.