Earlier quoted context omitted.
Tailwind example indeed does more, but only slightly. Would increase the size of CSS by 1-3%. The semantic version has clearly enough to prove the point the article attempts to make: significantly less code is needed and the resulting site is leaner & faster.
If you really want to compare code snippet sizes, you must offer the same functionality. Otherwise, the comparison is meaningless. You did the exact same thing before when you compared the Headless UI combobox with your nue.js implementation. Offering fewer features will result in less code. Shocker. Besides, I don't really care for these comparisons. If something is 2x longer code but more maintainable, it is 100% w…
Tailwind vs. Semantic CSS
121–130 of 211 posts
Re: Tailwind vs. Semantic CSS
#122Earlier quoted context omitted.
You claim that you can only move faster with Tailwind when one of these is true: when you don't care about 'badly structured' CSS, or when you are completely new to CSS, or when you don't care about reusable modules. I care very much about the structure of the CSS files I generate with Tailwind. I have been writing CSS for over 20 years. And I care very much about reusable modules – before good composable component s…
Copy/pasting directly from the article, because you have reworded my claims. Here's what I mean exactly: ---- You can move faster with Tailwind. But only when: 1. You are comparing Tailwind with your earlier, badly structured CSS or you are completely new to CSS development. 2. You don’t care about building reusable modules for later use. That is: you are not naming things that repeat. ----
Re: Tailwind vs. Semantic CSS
#123I never understood why use tailwind when I can have semantic css without any extra unusable content. Btw Bootstrapt is still there EDIT: Semantic css is also bandwidth friendly for mobile connection.
Re: Tailwind vs. Semantic CSS
#124> There is no need to write a component for every situation because you can use external CSS
Unless you're writing the most basic document-type html, this is awful advice. Even the tiniest widgets can be subject to a structural change. I can only think of the line: "Implement Select, 2000 issues" [1] Admittedly, CSS can correct the structure in some cases. Grid gives us more control over the arrangement, :before and :after can add elements... but in the end, you're just praying that you won't run into a requirement for which you need to update 200 html instances. The realisation that styling is inherently coupled to the structure, and that you will rarely have two components with both identical structure and style, is why css is generally scoped to each component.
For anything that is scoped globally, use a component.
[1]: I forgot where I picked this up, could've been a video for Radix-UI.
Re: Tailwind vs. Semantic CSS
#125Earlier quoted context omitted.
So ` ` is loose coupling, because the styling is not coupled directly into the element. You can completely switch the gallery design, by switching (or overriding, or modifying) the external stylesheet.
It is still coupled because the css will need to know the html structure in order to work. If you update the html, you probably need to update the css.
Re: Tailwind vs. Semantic CSS
#126Earlier quoted context omitted.
The coupling is in the right direction: designing possibly very advanced CSS to get a desired appearance from a given good markup, instead of compromising markup to simplify CSS.
The issue of this direction is if you need to update the markup, you will need to update the css, which is hard and risky because of css global scoping.
What kind of fragile markup and problematic CSS global rules are you worrying about?
Re: Tailwind vs. Semantic CSS
#127Earlier quoted context omitted.
So ` ` is loose coupling, because the styling is not coupled directly into the element. You can completely switch the gallery design, by switching (or overriding, or modifying) the external stylesheet.
I have rarely seen this work in practice in 20 years of CSS, but maybe in CSS Zen Garden. Yes, you can freely change the CSS. But usually changes are triggered by the HTML, like some information is added. This then requires you to change the CSS and likely break all sorts of other uses, which is not a problem with Tailwind.
as for tailwild, I just can't bare its wide-ness - too many className attribute string going over 150~300 char widths, with some ternary operators mixed on top...
(seems vanilla-extract / ete have better DX, with occasional inlining for immediate deadlines)
Re: Tailwind vs. Semantic CSS
#128This article does a good —if exaggerated— job of explaining the disconnect between markup and meaning, as well as the sheer volume of cruft. But tailwind does present well. Its plethora of sane defaults look… nice.
What I find myself doing more often than not is using tailwind classes in my handwritten SASS, using the @apply utility. I get tailwind's reset and typography but my markup isn't full of jank. PostCSS, PurgeCSS (or whatever's actually going on inside Vite) keeps everything small.
It's also good practice to try flying solo. A reset stylesheet and style everything, yourself. Few projects require that much CSS and it's a good excuse to try out some new ways of doing things. Because there are now several ways to accomplish major layout tasks, you can be quite expressive with CSS.
---
I've seen a few comments saying that maintenance is harder without utility CSS scattered throughout your markup. I think if you're struggling to maintain a semantic site, you're doing something wrong.
Even if you're using a complex SASS+Purge build chain, a sourcemap tells you exactly what's going on with a quick right-click-inspect. This method of development gives you a lot more space to split and comment on your source than you might want to in the middle of markup. Good component names help too.
Re: Tailwind vs. Semantic CSS
#129Earlier quoted context omitted.
Copy/pasting directly from the article, because you have reworded my claims. Here's what I mean exactly: ---- You can move faster with Tailwind. But only when: 1. You are comparing Tailwind with your earlier, badly structured CSS or you are completely new to CSS development. 2. You don’t care about building reusable modules for later use. That is: you are not naming things that repeat. ----
Sorry, I can't see any meaningful difference in my rewording. Could you clarify?
> when you don't care about 'badly structured' CSS
Is a completely different claim than this:
> You are comparing Tailwind with your earlier, badly structured CSS
I'm sure we both care about CSS structure. My claim talks about developers' past experiences. If you enjoy semantic CSS, you probably won't switch to (unsemantic) Tailwind. And vice versa: if you never mastered semantic CSS (even hated it), you are more eager to switch and find the new way more enjoyable.
Re: Tailwind vs. Semantic CSS
#130Author here. I implemented the commercial Tailwind "Spotlight" template with Semantic CSS and compared the differences in weight, amount of HTML and CSS, rendering speed, and best practices. I was surprised to find _that_ much overhead in Tailwind. Curious to hear your thoughts.
I have often used their components as a basis, and clean up huge chunks because I feel that is in my interest for future maintainability - it is not a fault of Tailwind, but a decision they made.
You can make a "semantic" design , using Tailwind where it will save you tiem or add readability, and get the best of both worlds.