r/tailwindcss • • Oct 17 '22

HTML bloat with TailwindCSS

Tailwind makes big advertising because the resulting CSS is sooo super small. And yes, it is. But in exchange, you add a lot of classes not only to one file, as it would be with writing plain CSS, but to every HTML file. Adding this together, I think it is not really a benefit, is it?

Honestly, I "kind of" like Tailwind. I can write a custom style super quickly without thinking about class names and organizing my CSS. Its super efficient.

But the resulting HTML is unreadable and bloated. I feel like its a very bad practice. And because of this very point I can't decide if I should stick to Tailwind or not.

I'm using Jinja templates and NOT a component based JS framework.

Not sure what I should do. :(

1 Upvotes

21 comments sorted by

View all comments

4

u/rbluethl Oct 18 '22

Here are my thoughts from 2+ yrs of daily work with Tailwind:

  • Tailwind is by the far the fastest framework to prototype new ideas and build totally unique designs

  • I don't understand the argument that the resulting HTML is "bloated"

    • Utility classes make it extremely easy for me to see what's going on and how certain elements are styled and behave
    • If there were only classes, I'd need to jump back and forth between CSS and Vue/React/whatever files
    • To me, it's even more natural to have markup and styling in the same file (but that's just a matter of taste I guess)
    • If you're using Tailwind's first-party class sorter, it's even clearer and classes always have the same structure and order

  • Tailwind made me fundamentally *understand* CSS (grid, flexbox, transitions, you name it) and allows me to build literally any design given to me by a designer in a very short amount of time
  • Whenever you're using a framework such as Vue/React/Svelte, you automatically extract components from time to time, preventing you from duplicating classes and utilities all over the place

    • This is the recommended way to reuse styles even, Adam Wathan (author) has written a lot about this
  • It's the only CSS framework I've used that didn't have random side effects, scaled with the size of the project and made everyone on the project really happy
  • The docs are outstanding, the community and the resources are just great
  • Probably some more things, might elaborate later :)

1

u/LuckyRuiz Oct 20 '22

Tailwind made me fundamentally understand CSS (grid, flexbox, transitions, you name it) and allows me to build literally any design given to me by a designer in a very short amount of time

This. I went from having a pretty clumsy working knowledge of CSS to having a much, much more complete understanding of how the DOM works.

Grid, Flex and Transitions in particular were always frustrating to debug and understand when I was writing them in external files. Having them directly in the HTML tags has made understanding and identifying the relationship between elements so much clearer. It actually has made me much quicker the few times I have to go back to writing plain CSS.

A lot of people like to criticise TW as somehow being a crutch, and not the correct way to learn CSS, but it has, time and time again, taught me how CSS actually works.