20

CSS4 should have nesting.

over 3 years ago from , Web Designer / Front-end Developer

:)

24 comments

  • Thompson GeorgeThompson George, over 3 years ago

    ok

    23 points
  • Daniel EdenDaniel Eden, over 3 years ago (edited over 3 years ago )
    1. “CSS4” isn’t really a thing. The CSS spec works in modules, each with their own independent levels. So filter, for example, is part of the Filter Effects Module Level 1, and box-shadow is part of CSS Backgrounds and Borders Module Level 3
    2. Specification for native CSS nesting is being drafted and is likely to become official spec judging by the popularity/demand for it. CSS specs only move forward with interest and support from web developers. You can even Tweet at the CSS Working Group to let them know you want nested selectors.
    15 points
    • Alec LomasAlec Lomas, over 3 years ago (edited over 3 years ago )

      The one thing I'm concerned about with the current spec is modifying the parent selector, which is hugely helpful for BEM. In Sass, for example, you can do:

      .block { display: relative; &__element { display: absolute; } }

      Which will create .block and .block__element selectors. If there's not a solution for this then native CSS nesting will be nice but not as powerful as I need it to be (which is fine, I suspect there will always be a need for preprocessors).

      4 points
  • Lennart SchoorsLennart Schoors, over 3 years ago

    You might get slightly smaller files, but other than that I don't see any advantages, only disadvantages: harder to learn, harder to avoid verbose selectors, more work for browser developers, more room for potential bugs, …

    That's why we have preprocessors, right?

    4 points
    • Chase GiuntaChase Giunta, over 3 years ago

      Imagine a world without preprocessors.... mind blown

      1 point
    • Adam Morgan, over 3 years ago

      But isn't the widespread use of preprocessors a sign that the tool itself may need to be modified to be the preprocessor?

      2 points
      • Robert Deniszczyc, over 3 years ago

        Not necessarily, just because thousands of developers use jQuery, Angular, React, etc doesn't mean they should be merged into JavaScript. If that happened you would end up with a language very difficult to work with and maintain.

        2 points
    • Colm TuiteColm Tuite, over 3 years ago

      Yep. Yep. Yep. And yep. Except larger files, not smaller.

      0 points
  • Kyo NagashimaKyo Nagashima, over 3 years ago

    There is no CSS Level 4. http://www.w3.org/TR/css-2015/#css-levels

    2 points
  • Mike HeitzkeMike Heitzke, over 3 years ago

    At this point, i'm more concerned/interested about what HTTP/2 means for how we build and serve products.

    1 point
    • Ole-Martin BrattengOle-Martin Bratteng, over 3 years ago

      I don't think HTTP/2 changes that much on how we build and serve products

      0 points
      • Mike HeitzkeMike Heitzke, over 3 years ago

        How do you figure? All of our performance best practices assume HTTP/1.1 protocol of batched asset download, minification, etc.

        Realistically i don't disagree with you, but it does require some rethinking of what we've been doing the last few years.

        0 points
  • Thomas Michael SemmlerThomas Michael Semmler, over 3 years ago

    If I could ban one word from the language, it would be should. I'm not sure what this actually is intended. Did you wanna open a topic for discussion? Because a smiley is not really an argument.

    0 points
  • hena ansari, over 3 years ago

    something you have to say that the sum the fact that I'm going to present your work a part in the study that was the supported by EX said company so there is that that area of conflict of interest the major ...Sheer no2

    http://t-rexmusclefacts.com/sheer-no2/

    0 points
  • Christoph Hochstrasser, over 3 years ago

    I don’t necessarily think that it has to be included. If you look at SASS & LESS coding guidelines in the community and at companies you will notice that most of them discourage the usage of nesting.

    So I think nesting could stay just as preprocessor feature, for people who absolutely need it.

    0 points
  • Jeff MartinJeff Martin, over 3 years ago

    Hm, not sure vanilla CSS needs nesting. Nesting is a double-edged sword, it's nice and useful if used right, but also introduces potential for a lot of complexity and misuse. I'd argue it's better in a preprocessor for people who specifically want to use them.

    0 points