The Future of CSS

(joshwcomeau.com)

145 points | by soheilpro 3 hours ago

21 comments

  • paczki 1 hour ago
    As someone who actively goes out of my way to stick to writing vanilla HTML/CSS/JS as much as possible, it's honestly hard to explain to people who only write within frameworks how good it's gotten. Use the proper tool for the job, of course, but it sparks joy!
    • yahoosakie 1 hour ago
      Yes!

      I've done the same for years, and it feels a little bit like the IQ bell curve meme, where on the left and right it is like "vanilla HTML/CSS/JS are all you need."

      • appplication 45 minutes ago
        This is an earnest question but is that really true for reactivity and state management? Of course with vanilla is all things are technically possible, but I feel like last I checked this wasn’t something well supported without really knowing what you’re doing.
        • 80fj0348i 13 minutes ago
          1. The tools available in vanilla have improved a lot recently and 2. LLMs have made niche skills/knowledge more accessible. SPAs still have their place but the average CRUD app is now really well served by vanilla or lightweight libraries like HTMX.
    • DimmieMan 44 minutes ago
      Definitely worth keeping up with as a framework user too.

      Smaller bundles, often easier to use, less bug potential. Code's a liability and being able to occasionally rip a bunch out as a feature becomes baseline is always a joy.

    • Tadpole9181 18 minutes ago
      I feel like I'm taking crazy pills.

      Y'all know React and Vue frameworks still use HTML, CSS, and JS, right? We're using the same thing, with a thin layer of helpers around mounting components and managing their lifetimes...

      • culi 12 minutes ago
        People who use css-as-an-object type of frameworks or tailwind don't really get to experience what writing CSS is like. styled-components or Linaria or Emotion do though ofc
  • CharlesW 2 hours ago
    Since I’m in before the negativity: I love CSS! For whatever reason, it’s always made sense to me. I have great respect for everyone with the tenacity to push on improvements that might take 5-10 years to be in common use, if at all.
    • culi 11 minutes ago
      We're pretty far past the 5-10 year timeframe now that browsers push updates so aggressively. It's pretty common to see features that were adopted just a year ago in common use
  • afavour 1 hour ago
    I’m part of the seeming minority that really enjoys working with CSS. And the way I use it today is so different than I did a few years back, e.g CSS modules, declaring a palette with variables then changing it for dark mode… it’s genuinely great to work with.
    • tvbusy 2 minutes ago
      I love working with CSS as well. It feels like the most optimized approach to me. However, it's really hard to use CSS as much once the project involves other engineers who don't have that level of interest in CSS.
    • paczki 1 hour ago
      Working with modern CSS is such a joy, and increasingly as time goes on I'm replacing huge chunks of JS with CSS which is a little boon in itself. Honestly, my only complaint is how long I have to actually wait to use new features.

      Nesting and @layers make maintaining CSS drastically easier than it once was as well.

    • nine_k 1 hour ago
      Also, grids and flexbox solve so many previously tricky layout problems. Animations obviate a bunch of small JS.

      I sometimes wish that CSS were reduced to the "good parts" and made simpler through it, but I realize that it's infeasible.

      • jamesfinlayson 1 hour ago
        Yeah with flexbox and fit-content/max-content is pretty fine now.
    • techpression 1 hour ago
      light-dark() is even better for that :) I also enjoy CSS, using @scope and @layer a lot with the :has() selector, it’s just so different now and I think most people are unaware.
  • watersb 1 hour ago
    The discussion here reminded me of one of my favorite demos, someone live coding Qt5 and QML on a first a generation Raspberry Pi, 1080p HDMI. Sort of a mashup of CSS and JavaScript for simple shaders. Fourteen years ago.

    https://youtu.be/0j-Wakm5B84?is=7dU_EvFyk_nQNwjO

    It's like a peek into a CSS future from a different timeline. Something we could have had.

  • alberth 1 hour ago
    Maybe I’m alone, but all of those suggestions seem to make CSS needlessly complex (or more like JS).

    Especially functions.

    Makes me think of a previous post from the author, who wrote 100k lines-of-code to power their blog.

    https://www.joshwcomeau.com/blog/how-i-built-my-blog-v2/

    • OuterVale 1 hour ago
      Worth keeping in mind that Josh's blog is absolutely over-engineered and I'm sure he'd admit that himself. He tried to keep parity with his rather complex course systems and his blog itself is a lot more than 'text on a page'.
    • beej71 1 hour ago
      At last I can realize my dream of writing a JS interpreter in CSS! ;)
      • paczki 1 hour ago
        offtopic here but what the heck, I am learning C from you right now! You finally made pointers click for me after failing to learn them a handful of times in the past. Legend!
    • gred 1 hour ago
      Yeah it looks to me like we're scraping the bottom of the barrel, if this is what's left.
    • SadErn 1 hour ago
      [dead]
  • koolala 1 hour ago
    The new responsively-sized iframes standard is an exciting one for me not mentioned. It's finally a step beyond the original frames and framesets. It will let us design sites out of iframes as building blocks instead of needing to use web components. Websites made out of websites.
  • herpdyderp 1 hour ago
    A bit strange to me how Josh beings with heralding the browsers working together and then every mentioned feature is Chrome only. They're nice previews for a potential future I suppose!
    • paulhebert 57 minutes ago
      The article is specifically about the “inter-op” program where the browsers work together on specific standards to bring to all browsers. (And we get to vote on the selection!)
  • manlymuppet 42 minutes ago
    Is there any implementation proposal which exists that makes relative corners automatic?

    If you want them now, you have to do sort of verbose and clunky calculations to get outer corner radius.

    [Outer Radius = Inner Radius + Padding](https://www.reddit.com/r/Design/s/oal9fZclJS)

    This seems like something standard enough to be a built-in feature.

  • kumarvvr 44 minutes ago
    I am very much excited for the future of CSS. And I love that functions are a part of it.

    I spent 3 months this year testing out a reporting system for large quantities of dynamic data.

    My requirement was to generate pdf reports, but didn't want any reporting tools and installations. Especially something like Microsoft Excel, which the old system was based on.

    After a lot of tests and proof-of-concept apps, I finally zeroed down to simple, pure, self contained html, that I am generating from a python script.

    And it's glorious.

    I am generating interactive charts when the html is viewed in the browser, and hiding all of them and only printing static svg images when in print mode, using css media print queries.

    And there is so much more.

    The format is awesome for ingestion by ai models.

  • lopsotronic 2 hours ago
    Been waiting a long time for CSS inherit() . . . although I freely admit that (and CSS Functions) open a respectable-sized can of worms. Sort of like what transclusion and conditionals do for document markup.

    Anchor Positioning would be sweet and doesn't feel like it's got so much baggage.

  • astrod 32 minutes ago
    I forgot about functions!

    I always thought that everything from Sass was pretty much ported over by now.

  • lioeters 2 hours ago
    Do we really want functions in CSS? I guess that ship has sailed a while ago, since CSS reached Turing completeness.

      /* Define a function: */
      @function --gradient-to-transparent(--color, --direction: bottom) {
        result: linear-gradient(
          to var(--direction),
          var(--color),
          transparent;
        );
      }
    
    Why not provide better integration with JavaScript, to make this kind of acrobatics unnecessary.
    • afavour 1 hour ago
      Because JavaScript requires… a lot. A virtual machine, script parsing, etc. Making that a requirement before you even display any content on the page would be a regression.
      • geocar 32 minutes ago
        We had that. It was called XSLT.

        Google said they weren't smart enough to implement it, or pay anyone to fix the one they forked a decade ago.

      • dlcarrier 1 hour ago
        If CSS is Turing complete, that means it has a virtual machine with parsing and so forth. That means that difference between it and JavaScript is just syntax. (Same for any Turing complete language)
      • lioeters 1 hour ago
        I can see that, but CSS already requires a lot, no? Especially as they keep adding new features to it.

        To me it feels like "programming in YAML", the way a declarative language/format acquires more and more features until you're writing functions in an awkward syntax that was never designed for it.

        • agstudio 36 minutes ago
          Strongly agree. While I am a huge fan of the capabilities of native CSS and the fact that it keeps getting more capable as time passes, I have come to the conclusion that it is unfortunately a programming language trapped in an “obsolete stylesheet syntax” body, especially after the addition of calc(), variables, functions and multiple ways of conditional logic.

          The worse part of working with CSS is that there is no standard static type checking tool (stylelint comes close though). A lot of programming errors should/could be caught at build time.

          Sometimes wondering if a completely alternative syntax+tooling is possible that would leverage all the existing capabilities, while using a different language paradigm.

          • chuckadams 18 minutes ago
            The ironic thing is that the old-school ancestor to CSS already was a programming language: DSSSL was a dialect of scheme.
        • afavour 1 hour ago
          It requires a lot… but a lot less than JS. The awkward declarative nature of it is a side effect of wanting it to parseable at speed.

          At an initial look I agree with you that the functions look very awkward. But I thought the same about CSS variables until I started using them and now I think they’re great so I’ll keep an open mind. I almost wonder if they would have been better off calling them “templates”, or something. “Functions” is going to make people think it’s just like JS.

          • lioeters 51 minutes ago
            Yeah OK, I see what you mean, I may change my mind once I start using them. And having worked on interpreters and compilers, I can understand the need to keep internals simple and fast - like everything must be parsable in one pass - so the surface ugliness of syntax isn't as important in the long term.

            Perhaps I should also be sympathetic to the spec authors, since they're working under tight constraints of language design. Things might look a lot more elegant if HTML/CSS/JS were designed from scratch as a coherent whole.

          • SadErn 1 hour ago
            [dead]
  • sneak 30 minutes ago
    CSS was done a long time ago. Stop changing it.
  • FDEUp 2 hours ago
    Say it with me:

    Broad support for new CSS features is GOOD.

    Making BASIC SITE FUNCTIONALITY depend upon new CSS features is bad.

  • asdfsa32 1 hour ago
    HTML and CSS are like bash, no one would use them if it wasn't for the fact that it is everywhere.
    • andsoitis 45 minutes ago
      Why would you pick something that isn’t ubiquitous? Being everywhere is the probably the most important feature for the vast majority of cases.
      • asdfsa32 23 minutes ago
        Because ubiquitous has nothing to do with any other quality like correctness, ease of use and ergonomics, good taste, robustness, and so on.
  • jamienk 2 hours ago
    Still can't tree shake. It's what makes my old css files grow into monsters. I feel like everyone has given up on this.
    • robertwpearce 1 hour ago
      For small-scale projects, I use a server-side helper for an HTML page to include only certain CSS, SVG, and JS on a page. Each JS file is tiny, progressive, vanilla JS; SVGs are predefined and generate an SVG sprite that I then consume; CSS pulls in a `base.css`, the page's CSS file, and any component ones pull in their own. It's hand-rolled per project (pre-AI being decent), but I'm proud of it, and it keeps every page tiny. HTTP/2 multiplexing is pretty good and downloads the files more or less in parallel.
    • afavour 2 hours ago
      CSS modules ought to make it possible. But it’s more or less impossible with regular CSS, you have no idea when a class/ID might be used.
  • slopinthebag 48 minutes ago
    this is like the webdev version of the c++ people who love talking about how great the modern version of their language is, ignoring the fact that all the bad stuff is still in there...

    remove inheritance and cascade from css and then we'll talk. but for now ill stick to tailwind.

  • derekhong 2 hours ago
    [flagged]
  • georgestones 44 minutes ago
    [dead]
  • jocelyner 1 hour ago
    [dead]
  • dolebirchwood 1 hour ago
    [flagged]