News for hackers. Stuff that matters.
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by h4x0rr on Sunday February 15, 2026 @03:54PM (#47027437)
Yeah let's do that. You have everything related to your component on place instead of jumping between files.
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by lawn on Sunday February 15, 2026 @04:12PM (#47027598)
Is jumping between files supposed to be difficult or something?
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by runarberg on Sunday February 15, 2026 @04:15PM (#47027621)
Also modern CSS is often written in a <style> tag either in a native web component or in a framework which supports single file component like vue or svelte.
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by chrisweekly on Sunday February 15, 2026 @04:23PM (#47027704)
Colocation is a useful principle in component-based architecture.
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by apsurd on Sunday February 15, 2026 @05:02PM (#47028096)
In my lived experience, shared components just become another problem. Especially in a fledgling company, the iteration velocity is actually negatively affected by shared libs because there's always overhead to (not) break legacy. so shared components bloat to address every evolving need.

And now with AI generated code i see so many wrapper patterns that forward endless props down, it's crazy!

TLDR: i almost always end up branching out into evergreen "reusable" components anyway.

Very unlikely the component library the CTO asked claude to DRY up the code with, is the one to rule them all.

Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by halfcat on Sunday February 15, 2026 @09:48PM (#47030331)
FWIW, “colocation in component-based architecture” doesn’t necessarily mean shared code. It can just mean the one thing has all of its parts in one place, instead of having HTML in one file, CSS in another, JS in another.

You’re right about DRY and code reuse very often being a premiere (wrong) abstraction, which is usually more of a problem than a few copy/pastes, because premature wrong abstractions become entrenched and harder to displace.

Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by temporallobe on Monday February 16, 2026 @12:35AM (#47031246)
As much hate as it gets, this is one thing I like about Angular.
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by cush on Monday February 16, 2026 @01:10PM (#47038186)
imo Angular would have won had it figured out a stronger path from v1 to v2
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by jamesfinlayson on Tuesday February 17, 2026 @01:28AM (#47044339)
Angular is pretty decent in that it gives you everything you need (the concept of a page and routing, services etc) but one thing I'll give React is the simplicity of changes to attributes just triggering updates.
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by pjmlp on Tuesday February 17, 2026 @03:20AM (#47044956)
From where I am standing it is mostly Angular or Next.js, both have separation of HTML and CSS by default, naturally they cannot block someone to come in and put tailwind on the project.
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by afiori on Sunday February 15, 2026 @04:39PM (#47027848)
Without a lot of discipline it is very easy to end up with a css with lots of unclear and hard to guess effects. Eg consider the case of <A type=1><B><A type=2></A></B></A> where A and B are complex templates. Any selector with the " " operator on A risk expanding to the inner A even if it was intended only for the outer. Similarly a :has selector might catch a descendant of the wrong element.

@scope fixes a lot of this, but it is a complex problem. With tailwind you mostly have to worry about inheritance

Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by robertoandred on Sunday February 15, 2026 @05:08PM (#47028161)
This problem was solved a long time ago with CSS Modules.
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by christophilus on Sunday February 15, 2026 @06:00PM (#47028643)
I prefer almost anything to CSS modules, so this bike shedding topic is probably very subjective.
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by the_other on Monday February 16, 2026 @04:37AM (#47032924)
> Any selector with the " " operator on A risk expanding to the inner A even if it was intended only for the outer.

Then <a type=b> is potentially a <c>. Consider a small refactor?

Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by ewuhic on Sunday February 15, 2026 @04:41PM (#47027871)
Is staying in one file supposed to be difficult or something?
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by luckylion on Sunday February 15, 2026 @05:20PM (#47028274)
this is grey text from tailwindcss.com, I wouldn't call it easy and readable.

<div class="relative before:absolute before:top-0 before:h-px before:w-[200vw] before:bg-gray-950/5 dark:before:bg-white/10 before:-left-[100vw] after:absolute after:bottom-0 after:h-px after:w-[200vw] after:bg-gray-950/5 dark:after:bg-white/10 after:-left-[100vw]"><p class="max-w-(--breakpoint-md) px-2 text-base/7 text-gray-600 max-sm:px-4 dark:text-gray-400">Because Tailwind is so low-level, it never encourages you to design the same site twice. Some of your favorite sites are built with Tailwind, and you probably had no idea.</p></div>

Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by what on Sunday February 15, 2026 @07:50PM (#47029525)
That’s actually disgusting.
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by paradox460 on Sunday February 15, 2026 @10:03PM (#47030403)
It gets worse

Check out the Netlify admin dashboard screenshot in my blog post

https://pdx.su/blog/2023-07-26-tailwind-and-the-death-of-cra...

Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by troupo on Monday February 16, 2026 @03:20AM (#47032345)
There's nothing in Tailwind that makes the craftsmanship dead, and your proposed solution with scoped styles somehow a revival of said craftsmanship.

Note how your solution literally depends on a build tool (Vue) to work. Whereas Tailwind can work with no build tools (tailwind build tools removes unused classes, and that's mostly it).

And then you go:

--- start quote ---

Juniors still come along and just do margin: 13px. In tailwind, they do m-[13px]. No difference. At least with CSS its centralized.

--- end quote ---

When your scoped CSS example is literally decentralized per-file CSS that has `margin: 5px` in it. That gets compiled into a meaningless `class-678x8789g` by the build tool.

> The people I've seen who are most excited over tailwind are generally those that would view frontend as something they have to do, not something they want to do.

Tailwind is the product of its era: where even sites are composed out of components. That is, this separation of concerns: https://x.com/simonswiss/status/1664736786671869952

As a comparison, here's Youtube's expertly crafted CSS (which is actually an improvement over their original 6B file). Note how much endless repetition there is: https://www.youtube.com/s/_/ytmainappweb/_/ss/k=ytmainappweb...

Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by UqWBcuFx6NV4r on Monday February 16, 2026 @05:15AM (#47033236)
Great. Another overly dramatic blog post from years ago from someone with a chip on their shoulder, calling that the sky is falling, when it’s very clear that it didn’t actually fall.
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by halfcat on Sunday February 15, 2026 @09:55PM (#47030369)
In my editor this looks like this, with an extension like Tailwind Fold or Inline Fold:

    <div class="...">
      <p class="...">
        Because Tailwind is so low-level, it never encourages you to design the same site twice. Some of your favorite sites are built with Tailwind, and you probably had no idea.
      </p>
    </div>
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by dwb on Monday February 16, 2026 @03:21AM (#47032351)
Ok, and how does it look when you want to read or edit the “classes”?
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by dagi3d on Monday February 16, 2026 @04:40AM (#47032954)
yeah, Tailwind feels to me like a "write-only" solution.
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by dbbk on Sunday February 15, 2026 @08:53PM (#47029992)
You can literally command click a class to go into a styled components css file. I do not understand what the big issue is.
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by halfcat on Sunday February 15, 2026 @09:40PM (#47030290)
Cognitive load of looking at 12 open files trying to understand what’s happening. Well, in fairness some of those 12 are the same file because we have one part for the default CSS and then one for the media query that’s 900 lines further down the file.
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by bobthepanda on Monday February 16, 2026 @01:02AM (#47031389)
Css modules gets away from the larger sins of the massive global css files.

If modules had existed much earlier it probably would’ve gotten rid of most of the awfulness.

Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by UqWBcuFx6NV4r on Monday February 16, 2026 @05:13AM (#47033221)
Oh, great. So let’s just 2x all our files then! All for, what exactly?

It sounds like you just want to write Java.

Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by bobthepanda on Monday February 16, 2026 @01:14PM (#47038223)
If you have a complaint about your styles being so complicated and in a giant 900 line mega file, I don’t see how you address physical size other than breaking up the file.

Granted, nesting support was also added fairly recently in the grand scheme of things, which boggles the mind given how it was such an obvious problem and solution that CSS preprocessing came about to address it.

Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by agos on Monday February 16, 2026 @10:01AM (#47035856)
CSS Modules are way older than Tailwind, but alas it was not enough
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by dbbk on Monday February 16, 2026 @11:58AM (#47037365)
What do you mean 12 files? It’s 2 files. One for your component and one for its styles module.
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by onion2k on Monday February 16, 2026 @02:16AM (#47031890)
Yes.

The problem is that the styles for something can be defined in multiple places, and that makes it hard. Especially with CSS and (potentially) having specificity issues if things aren't managed well. Having them as a part of the component means that problem goes away.

Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by mattacular on Monday February 16, 2026 @11:12AM (#47036807)
I find it to be more difficult. Especially if I can't pane the files in view comfortably (ie. beyond 2 or 3 it gets significantly harder to work across them).

Some frameworks or coding styles really lean into having lots of tiny files. That necessitates a more complicated directory structure for the project. Locating files eventually tends to requires search capability rather than being able to look through the tree in a sidebar.

None of this is "hard" per se but I find the opposite is nicer to work with typically.

Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by paradox460 on Sunday February 15, 2026 @09:51PM (#47030339)
Vue, Svelte, and Surface manage to do this without forcing you to inline all your styles
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by h4x0rr on Monday February 16, 2026 @02:00AM (#47031755)
I worked with both. Scoped styles are nice. Tailwind is better - no naming of every element, no mental tax of jumping around in the file -
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by Kiro on Monday February 16, 2026 @07:04AM (#47034002)
Jumping up and down in the file is not much better and you still need to come up with names for classes. I want to look at an element and immediately know how it's styled.
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by agos on Monday February 16, 2026 @09:56AM (#47035797)
From Tailwind's home page:

<div class="h-112 p-4 sm:p-8 relative overflow-hidden rounded-lg bg-gray-950/[2.5%] after:pointer-events-none after:absolute after:inset-0 after:rounded-lg after:inset-ring after:inset-ring-gray-950/5 dark:after:inset-ring-white/10 bg-[image:radial-gradient(var(--pattern-fg)_1px,_transparent_0)] bg-[size:10px_10px] bg-fixed [--pattern-fg:var(--color-gray-950)]/5 dark:[--pattern-fg:var(--color-white)]/10">[...]

"immediately" is a stretch

Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by Kiro on Monday February 16, 2026 @10:33AM (#47036292)
You can fold it, format it, and IDEs preview it. This is like me posting the equivalent CSS in one big line. But even without all that I still prefer this over dealing with cascading styles in stylesheets. Never again.
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by agos on Monday February 16, 2026 @10:54AM (#47036593)
dealing with the cascade and tailwind are not the only two options
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by rafark on Monday February 16, 2026 @12:22PM (#47037631)
Thanks for proving the point. I haven’t even seen that element rendered and I already have a good mental picture of what it is and what it looks like.
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by cush on Monday February 16, 2026 @01:02PM (#47038090)
I think your point has very little to do with tailwind and everything to do with CSS. Tailwind is optimized for modification and maintainability. We could replace your example with

<div class="hero-header hero-header--large">...

but now any time we want to modify hero-header, we're trolling through the whole site to find where else these classes might be used so we know what to test to avoid breaking anything

Sure it's easy to look at the element you shared and say it's too complex (it's really not, it's very declarative), but the complexity must live somewhere, and I'd choose Tailwind over any other prevailing system because it's isolated and safe to modify

Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by zelphirkalt on Monday February 16, 2026 @05:08AM (#47033193)
What stops you from doing the same thing in CSS? It is trivial to assign a specific CSS class to an element that is the root node of a "component" and scope rules under that.