After years of developer frustration and questions on online forums, it’s finally happening: CSS is getting an if() function to apply styling when a condition is met. For the first time, developers can make logical decisions directly in stylesheets, without separate code blocks. This opens up whole new possibilities for web designers.

  • trolololol@lemmy.world
    link
    fedilink
    arrow-up
    11
    ·
    15 days ago

    What an abomination

    I’m just curious what kind of bad code is going to be around when this gets widespread.

    • python@lemmy.world
      link
      fedilink
      arrow-up
      2
      ·
      15 days ago

      No worries, we really bad web developers have all switched to React long ago 😎 So no CSS here, just Material-UI’s “sx” attribute plastered over every single component.

  • mormund@feddit.org
    link
    fedilink
    arrow-up
    9
    ·
    16 days ago

    Only in Chromium for now. Also I don’t see how it adds any new capabilities? I guess it is a little nicer syntax wise in some cases, but I might still prefer SCSS nested declarations instead.

  • phneutral@feddit.org
    link
    fedilink
    arrow-up
    6
    ·
    15 days ago

    This breaks with the foundations of CSS. You already can build if-like statements especially since the implementation of custom properties. It doesn’t have to be that explicit — quite the contrary: putting if() into every property will make them bloated and harder to understand.