Should I just default everything as display: flex ?

Thursday, February 6th 2025

I don't really like having utility-based CSS classes, like having a .flex class to make elements use Flexbox... but boy, sometimes, I'm tempted to.

I find myself using Flexbox for almost every single piece of layout these days. Sometimes it's inline-flex, and on rare occasions I use grid. (or straight up tables)

At some point, my stupid ass was thinking "wait, I already use normalizers stylesheets. Maybe I should just have a * rule for display: flex, and THEN figure stuff out."

It makes sense on paper, right ? Well, no, not even there, but it was interesting enough to entertain it.

The upside would be winning a lot of time on layout styles.

And then, I tried to list the downsides :

  • Pretty sure it screws over any non display:block element. (tables, lists, etc)
    • Pretty sure it screws over p and other similar text based elements.
      • Pretty sure it screws over nicher elements like legend.

        Yeah, i'm not gonna list everything, but it seems very flawed an idea. Maybe I could make a rule for the layout elements (header, footer, div, nav, section...)

        That seems more sensible : that would actually be helpful AND not be a nuclear wasteland solution.

        I don't know, just something to think about !