Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I very strongly agree. Mandatory & makes things much clearer, for a negligible cost. (And really, the curly braces, colon and semicolon are all mandatory (well, except the last semicolon of a ruleset), and alternative syntaxes with less punctuation like Sass’s have failed; the & is frankly more consistent than its absence.)

For a more technical justification: with optional &, priority is given (by brevity) to the descendant combinator, but what of other combinators? Do they require & or not? It could reasonably go either way. I haven’t read recent proposals, but am very familiar with CSS grammar, and I’m genuinely unsure.

  parent {
      /* This might or might not work. */
      > child {
          …
      }
  }

  parent {
      & > child {
          …
      }
  }


This is another good point, particularly because (IMHO) people tend to overuse the descendant combinator in places where they should really use the child combinator instead.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: