News for hackers. Stuff that matters.
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by ktpsns on Sunday February 15, 2026 @03:41PM (#47027324)
CSS in 2025: Let's write html inlined styles as if it was 2005 and separation of formatting/representation was never invented. I talk of tailwind, of course.
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.
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by crooked-v on Sunday February 15, 2026 @04:32PM (#47027785)
Tailwind is a direct response to how the "C" in "CSS" actually sucks, so there's no surprise that it's so popular.
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by spartanatreyu on Sunday February 15, 2026 @06:46PM (#47029031)
The "C" (Cascade) in CSS doesn't suck, the education about it sucks.

People don't know how it works, then things go wrong so they learn to work around it.

That's what led to things like div + class soup that you get with the BEM naming convention or Tailwind.

The cascade is actually awesome, super powerful and if you know how to use it, it can greatly simplify your code.

Education is the problem and the solution.

---

To anyone outside the CSS space, this is the closest analogy I can find:

In the American education system, there was a recent-ish change where children are "taught" to read using a method of just learning the shape of every word (e.g. "thermally" has a th at the start and ly at the end, so it must be the word "thermally", despite other similar looking words like thematically).

The method was disproven but the American education system still uses it.

Now illiteracy rates are climbing where almost 1/4 Americans (USA) can't read.

It's basically the same thing with CSS, where developers don't know what the code they're reading/writing is actually going to do.

Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by paradox460 on Sunday February 15, 2026 @10:07PM (#47030422)
I call it cargo cult developing. People develop bags of spells and tricks that they attempt to apply to a situation to solve a problem. Usually they can arrive at a solution by trying a number of these incantations, but not always. And never actually ask them what the incantation does

It's not just css either. At a job I've worked, we had a VPN client that would get into a weird state, where it needed to be killed to restart. An incantation that made use of ps, grep, awk, and xargs was provided, instead of just using pkill

Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by troupo on Monday February 16, 2026 @03:30AM (#47032415)
> That's what led to things like div + class soup that you get with the BEM naming convention or Tailwind.

You could try and think why people end up with BEM or Tailwind. And the answer isn't "because people are not educated about cascade". Both BEM and Tailwind came form people who are very much aware of the cascade.

The problem is that cascade is very much a hindrance in quite a few cases. Especially when you deal with components and design systems.

> To anyone outside the CSS space, this is the closest analogy I can find

All analogies are bullshit.

The truth is that CSS is designed for documents, and for a few decades people have been trying to use it to design/build components: https://x.com/simonswiss/status/1664736786671869952 Cascade is good for the former, and is death for the latter.

And browser vendors have been surprisingly stubborn when it comes to making any improvements to the DX in this area. That's why instead of locally scoped CSS, CSS nesting, CSS mixins (and a bunch of other improvements from SASS and various JS Frameworks) we first got 15 000 JS-only specs around web components, of which 14 999 can be covered by improvements to CSS.

> where developers don't know what the code they're reading/writing is actually going to do.

Lol. Tailwind has made people more aware of what CSS does, with better documentation, than decades of bullshit articles and millions of words of existing docs.

Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by TonyStr on Monday February 16, 2026 @03:52AM (#47032583)
What do you think is lacking from CSS education?

I don't think anyone in this thread is arguing that inheritance or specificity is hard to understand.

My issue with cascading style sheets is mainly that namespace pollution (as every selector is defined in the same global namespace) means that short selectors (.separator, .highlight, .button) are likely to collide with completely unrelated parts of the application. BEM and tailwind are popular because they localize styles to specific components, preventing namespace issues. Today, most web frameworks deal with components, so it makes a lot of sense to localize the styles to the components. Scoped css in vue/svelte allows you to write short selectors, and have them only apply to the component they are written in, without needing to prefix them with a component name.

Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by gf000 on Monday February 16, 2026 @04:30AM (#47032860)
It has nothing to do with education, software development is not learnt in a centralized way so you could hardly claim anything based on that.

Cascading simply fails to scale/work with web applications, especially when multiple people work in parallel.

HTML both describes content AND layout, so you simply can't separate the two. This was a nice dream when the internet was "markdown encoded in html", but the moment you write a nested <div> for layout purposes you lost. So HTML has to be written together with CSS, so we get no separation. Now what is it that you could meaningfully cascade? (If anything, variables are all that we needed)

Add to it that people are using third-party components as well, and now many "widgets" starts by resetting outside styling rules.

Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by WorldMaker on Monday February 16, 2026 @11:06AM (#47036733)
Reading word shapes comes from a place of good, studied intent. Reading word shapes is how people who read quickly read. It is in many ways an advanced way of reading. Trying to jump to it was a hope that you could shortcut some of the literacy curve. Unfortunately, trying and sometimes failing to read word shapes is also how some neurodivergent brains work naturally (the family of dyslexias as the big complex elephant in the room). If your brain jumps directly to word shape, and somewhat often gets it wrong, being forced to slow down, break words apart and start from smaller basic building blocks can be helpful.

It's a reminder that different people learn at different paces.

I think overall the additional details expand and perhaps better the metaphor: a lot of people want to jump directly to the advanced CSS stuff and skip the fundamentals. For some people that works and may be a shortcut. Other people need to spend more time breaking their teeth on the fundamentals, getting them wrong, learning from their mistakes, and getting rock solid on the slower building blocks before trying to do anything advanced.

Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by cush on Monday February 16, 2026 @02:04PM (#47038879)
Instead of assuming that everyone who has a different preference than you is ignorant, it might be helpful to look at the problems that each technology solves and the requirements they fulfill.

The cascade is a huge issue for teams need to be able to safely modify one area of a site without accidentally impacting others. Tailwind solves organizational problems by colocating the styles with the elements - allowing changes to be surgical, declarative, and predictable. Editing and removing styles is as easy as modifying the content of the page.

Yes, the cascade is super powerful, but it needs to be contained somewhat to scale to many developers and large codebases.

> 1/4 Americans (USA) can't read

Also even though your analogy has nothing to do with CSS, I have to point out that this absolutely isn't true (which in the context of your argument about education is pretty ironic)

Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by dbbk on Sunday February 15, 2026 @08:54PM (#47029996)
I mean, the cascade really doesn't suck though does it. You really want to set font families and sizes on every p tag?
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by mattlondon on Sunday February 15, 2026 @04:33PM (#47027792)
Wait until you see React & JSX...

At least html and CSS are both presentation. React/JSX now confuses presentation and business logic.

Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by lateforwork on Sunday February 15, 2026 @04:44PM (#47027913)
> React/JSX now confuses presentation and business logic

React was originally designed to be the "V in MVC". You can still use it that way. React becomes very simple when you only use it as the V in MVC.

Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by azangru on Sunday February 15, 2026 @04:48PM (#47027948)
What are the M and the C, and how do they talk to the V in this case?
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by apsurd on Sunday February 15, 2026 @04:54PM (#47028010)
react can be pure functions that take in props. Given a set of props, ideally data primitives, the outputted view is guaranteed. it's nice.

In practice, the entire JS ecosystem enjoys flying off the rails, every season, but it's not strictly react's fault.

To answer your question, however those props get into the component is up the the M & C. can be async server, or shoved in as json in the script tag.

Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by azangru on Sunday February 15, 2026 @05:00PM (#47028080)
If you move the data (the M and the C) entirely out of react, and only pass it in via props, there would be only one place — the root react node — where the props could get into react. Is this what you have in mind? Or are you envisioning multiple root nodes?
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by apsurd on Sunday February 15, 2026 @05:10PM (#47028174)
Well, i've always been a fan of the island architecture that effectively mounts root nodes as little islands of isolated state, yes.

Mainly this avoids the hell that global state SPA patterns produce: redux, reducer patterns in general, and 8 thousand context providers.

I do think there's use cases that warrant global in-memory state, but it's such a pain in the ass to maintain and evolve, i'd always plan against it. Every html node in your app does not need to know about literally everything going on and react instantly to it. it just doesn't.

Just make another page!

Also: so the islands pattern can be as fancy or rudimentary as desired. they can bootstrap themselves via async endpoints, they can be shipped as web components even, or they can be static, pre-hydrated in some manner.

Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by kittbuilds on Sunday February 15, 2026 @05:14PM (#47028204)
The islands pattern is underrated for maintainability. I've found the biggest win isn't even the state isolation — it's that each island can have a completely independent upgrade path. You can rewrite one island from React to vanilla JS (or whatever comes next) without touching anything else.

The global state SPA pattern fails for a more fundamental reason than just being painful to maintain: it creates an implicit contract between every component in the app. Change one reducer and you're debugging side effects three layers away. Islands make the contract explicit — each one owns its data, full stop.

The one gotcha I've hit is cross-island communication. PostMessage works but gets messy. Custom events on a shared DOM ancestor end up being the cleanest pattern for the rare cases where islands genuinely need to coordinate.

Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by seer on Sunday February 15, 2026 @10:11PM (#47030444)
Do you need react at this point? Isn’t it just html/css/components?

I remember the birth of React was because Facebook had a problem - you would add a comment and your notification bar would sometimes not get updated.

They had so many bugs with normal html / css that they wanted to solve this on the application layer - to make inconsistent UI elements unrepresentable.

So they came up with react with global state - because in their use case changing one thing does affect a bunch of other unrelated things, and they all need to sync together.

I mean honestly that’s what I use React _for_ - especially with contexts it’s very easy to express all of this complex interconnected state of a webapp in a consistent way.

And of course there are other ways to solve it - for example with elixir/phoenix you just push all that complexity to the backend and trust in websockets and the BEAM.

I just feel that if you really don’t need global state, then react kinda isn’t needed as well…

Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by gf000 on Monday February 16, 2026 @04:34AM (#47032890)
> I just feel that if you really don’t need global state, then react kinda isn’t needed as well…

I don't know, in my mind "re-render (efficiently) when state changes" is the core point of react and similar frameworks. That requirement still stands even if I have a smaller, local state.

Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by tim1994 on Sunday February 15, 2026 @05:06PM (#47028136)
With signals you can avoid the prop drilling. I think signals can help a lot with this approach
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by azangru on Sunday February 15, 2026 @05:27PM (#47028348)
I think the parent wants to separate the V from the M/C. If you smuggle signals inside of components to avoid prop drilling, you would be coupling the M/C and the V. I suppose that's not what the parent has in mind.
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by WorldMaker on Monday February 16, 2026 @11:12AM (#47036813)
That is the classic Flow model or Redux model (if you prefer the common implementation name over the Facebook paper name). Build a central store. Pass the single store down to all necessary components via prop-drilling, then later Contexts (and HOCs) to skip layers as a nice-to-have.

Redux is a lot less fashionable today, but hasn't entirely disappeared as an M and C option.

Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by lateforwork on Sunday February 15, 2026 @04:58PM (#47028057)
M stands for Model layer. This layer handles business logic and knows nothing about UI. It does not have any html or CSS.

V stands for View. This layer handles HTML and CSS. You can use React here.

C stands for Controller. Controllers know about Views and Models and which model objects to instantiate for which view. It makes REST API calls and does caching, and handles errors. Controllers know about the application state and decide what page to display next.

For an application written in this style see: https://github.com/wisercoder/eureka/tree/master/webapp/Clie...

(This app doesn't use React, but does use TSX, and you could use React as well).

Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by cbarrick on Sunday February 15, 2026 @04:53PM (#47028004)
- M for Model: your data model. - V for View: views of your data. - C for Controller: does stuff with your data.
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by Chris_Newton on Sunday February 15, 2026 @07:12PM (#47029245)
In the original MVC architecture, the fundamental idea was that the model was responsible for storing the application state, a view was responsible for rendering output to the user, and a controller was responsible for responding to user interactions.

The model can be completely unaware of any specific views or controllers. It only needs to provide an interface allowing views to observe the current state and controllers to update that state.

In practice, views and controllers usually aren’t independent and instead come as a pair. This is because most modern UIs use some kind of event-driven architecture where user interactions are indicated by events from some component rendered by the view that the controller then handles.

My go-to example to understand why this architecture is helpful is a UI that features a table showing some names and a count for each, alongside a chart visualising that data graphically. Here you would have a model that stores the names and counts as pure data, and you would have two view+controller pairs, one managing the table and one the chart. Each view observes the model and renders an updated table or chart when the model state changes. Each controller responds to user interactions that perhaps edit a name or change its count — whether by typing a new value as text in an editable table cell or by dragging somewhere relevant in the chart — by telling the model to update its state to match (which in turn causes all views observing the model to refresh, without any further action from whichever controller happened to be handling that user interaction).

In practical terms for a React application, we might implement this with a simple object/Map somewhere that holds the names and values (our “model”) and two top-level React components that each get rendered once into some appropriate container within the page. Each component would have props to pass in (a) the current state and (b) any functions to be called when the user makes a change. Then you just write some simple glue logic in plain old JavaScript/TypeScript that handles keeping track of observers of the model, registering an observer for each top-level component that causes it rerender when the state changes, and providing a handler for each type of change the user is allowed to make that updates the state and then notifies the observers.

There are lots of variations on this theme, for example once you start needing more complicated business logic to interpret a user interaction and decide what state change is required or you need to synchronise your front-end model state with some remote service. However, you can scale a very long way with the basic principle that you hold your application state as pure data in a model that doesn’t know anything about any specific user interface or remote service and instead provides an interface for any other modules in the system to observe and/or update that state.

Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by kristopolous on Sunday February 15, 2026 @08:26PM (#47029792)
Mvc is why there's 3 languages: HTML CSS and JavaScript

The separation is already there

People have just failed to understand it

Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by gf000 on Monday February 16, 2026 @04:40AM (#47032950)
Then we surely don't need to add random additional elements to our Content, purely to properly layout the content right, which is the job of the View?
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by azangru on Monday February 16, 2026 @06:33AM (#47033814)
> The separation is already there

I wonder how you would map these three onto M, V, and C :-)

Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by kristopolous on Monday February 16, 2026 @06:51PM (#47041922)
In the late 1990s there were a number of working groups for the w3c who were very familiar with the MVC paradigms.

Out of those multi-year-long working groups came cascading style sheets and their revisions along with JavaScript features like dom access.

The dominant paradigm is to let their work go unread and call it a flex.

I've frequently been belittled and mocked in online negging when I encourage people to take a deep dive and learn something new.

I'm not here to debate people who think mockery and dunking on people that have done hard work is good faith behavior

Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by est on Sunday February 15, 2026 @09:15PM (#47030137)
> React was originally designed to be the "V in MVC"

React was originally desingned to be php in the browser.

php5 -> HHVM -> Hack -> XHP -> JSX

Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by rafark on Monday February 16, 2026 @12:27PM (#47037699)
Omg yes finally someone acknowledges this. I am always pointing out how react and jsx are a port of XHP. This is why react was class based at first (because php is a class based OO language).

Hack was created later though. XHP was a php 5 extension created around 2008

Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by madeofpalk on Sunday February 15, 2026 @05:05PM (#47028129)
I think you're confusing business logic with view logic.
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by bromuro on Sunday February 15, 2026 @04:58PM (#47028053)
React is great for MVVM indeed. Who is still using MVC in 2026?
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by flowerlad on Sunday February 15, 2026 @05:12PM (#47028191)
MVVM was invented by Microsoft for 2-way syncing in WPF. Today we know 2-way syncing is a mistake.

Who uses MVC in 2026? Pretty much every framework out there, including Java frameworks and Python frameworks and .net

Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by ozim on Sunday February 15, 2026 @06:19PM (#47028796)
You have any more sources on MVVM being a mistake?

I found WPF rather nice to work with. Same with knockout.js and Angular I don’t see much downsides.

Everyone can write bad code of course in each of them but I think it was working quite well.

Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by lateforwork on Sunday February 15, 2026 @07:22PM (#47029312)
When React launched in 2013, its defining idea was strict one-way data flow: parents pass data down via props, and updates happen in a clear, explicit place. Children can't mutate parent state directly; they signal changes through callbacks. The result is predictable, traceable state changes.

This contrasted with MVVM frameworks like early AngularJS, Knockout, and WPF, which relied on two-way data binding. That automatic syncing felt convenient for small apps, but at scale it often led to hidden coupling and hard-to-trace update chains.

Over time, many developers came to view pervasive two-way binding as a design mistake in complex systems. React's unidirectional model gained traction because it favored clarity and control over "magic."

Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by ozim on Monday February 16, 2026 @01:47AM (#47031672)
Thanks GPT but I know all of that. I was expecting some eye opening new evidence because person I was asking seemed really confident and using strong words.

But that’s just generic „blablabla”. MVVM is not a mistake and is still plenty useful.

Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by lateforwork on Monday February 16, 2026 @12:25PM (#47037668)
If it is useful for you then it is not a mistake. For you.
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by aloisdg on Sunday February 15, 2026 @07:03PM (#47029173)
Isn't Vue also MVVM?
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by ozim on Monday February 16, 2026 @01:58AM (#47031744)
Yes VUE is quite a descendant of knockout.js.

People confidently write strong opinions on the internet.

Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by recursive on Sunday February 15, 2026 @11:39PM (#47030955)
I've heard many people assert that 2 way binding is a mistake, but I didn't think it was settled. It still seems simpler to me than so called uni-directional data flow.
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by interlocutor on Sunday February 15, 2026 @05:25PM (#47028323)
Ever heard of Django? ASP.NET? Most UI frameworks, including ASP.NET Core, Spring Boot (Java based framework), Ruby on Rails, and Django (Python) are all based on MVC.
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by Kerrick on Sunday February 15, 2026 @06:36PM (#47028950)
Those are all stateless MVC over HTTP, which is a very different architecture from stateful MVC for long-lived UI. The latter was invented for Smalltalk by Trygve Reenskaug, and is far more relevant to front-end web.

Stateful MVC uses Publisher/Subscriber (or Observer) to keep Views and Controllers up-to-date with changing Models over time, which is irrelevant for stateless MVC over HTTP. Plus, in stateful MVC the View and Controller are often "pluggable," where a given Controller+Model may use a different View for displaying the same data differently (e.g. table vs. pie chart), or a given View+Model may use a different Controller for handling events differently (e.g. mouse+keyboard vs. game controller). Whereas, in stateless MVC over HTTP, the controller is the "owner" of the process, and won't generally be replaced.

And in the world of front-end web, stateful MVC really is mostly dead. MVVM and Component-based architectures (using the Composite pattern) have replaced it. A runtime is usually responsible for wiring up events, rather than individual controllers. Controllers don't need to be swappable because events can be given semantic meaning in components, and Views don't need to be swappable because you can instead render a sub-composite to change how the data is shown.

Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by lateforwork on Sunday February 15, 2026 @07:13PM (#47029250)
Whether application state is short-lived (e.g., request/response CRUD) or long-lived (e.g., an in-memory interactive UI) is orthogonal to MVC. MVC is a structural separation of responsibilities between model, view, and control logic. The duration of state affects implementation strategy, not the applicability of the pattern itself.
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by Chris_Newton on Sunday February 15, 2026 @07:42PM (#47029450)
MVC is a structural separation of responsibilities between model, view, and control logic.

Yes, but the “MVC” pattern used by various back-end web frameworks that borrowed the term a while back actually has very little to do with the original MVC of the Reenskaug era.

The original concept of MVC is based on a triangle of three modules with quite specific responsibilities and relationships. The closest equivalent on the back-end of a web application might be having a data model persisted via a database or similar, and then a web server providing a set of HTTP GET endpoints allowing queries of that model state (perhaps including some sort of WebSocket or Server-Sent Event provision to observe any changes) and a separate set of HTTP POST/PUT/PATCH endpoints allowing updates of the model state. Then on the back end, your “view” code handles any query requests, including monitoring the model state for changes and notifying any observers via WS/SSE, while your “controller” code handles any mutation requests. And then on the front end, you render your page content based on the back-end view endpoints, subscribe for notifications of changes that cause you to update your rendering, and any user interactions get sent to the back-end controller endpoints.

In practice, I don’t recall ever seeing an “MVC” back-end framework used anything like that. Instead, they typically have a “controller” in front of the “model” and have it manage all incoming HTTP requests, with “view” referring to the front-end code. This is fundamentally a tiered, linear relationship and it allocates responsibilities quite differently to the original, triangular MVC.

Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by gf000 on Monday February 16, 2026 @04:52AM (#47033047)
Is the Controller not in a coupled pair with a View? We could imagine an interface where it could be completely separate (e.g. a kiosk TUI where stuff like "press 'r' for X" is displayed), but in the vast majority of UIs the View has state, and the Controller has to depend on that state (e.g. did this keypress happen with a text field focused). Sure, this is abstracted away via the UI framework and we operate on usually some form of event system.

But even then, I don't really see how we could have a non-coupled controller-view. In fact, I seem to remember that it was described in a similar way for Smalltalk even.

Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by black3r on Monday February 16, 2026 @06:45AM (#47033881)
You can have decoupled Controllers from Views using React. That's the basis of the "original" Flux/Redux architecture used by React developers 10+ years ago when React was just beginning to get traction.

A flux/redux "Store" acts as a Model -> contains all the global state and exactly decides what gets rendered. A flux/redux "Dispatcher" acts as a Controller. And React "Components" (views) get their props from the "Store" and send "events" to "dispatcher", which in turn modifies the "Store" and forces a redraw.

Of course they aren't "entirely decoupled" because the view still has to call the controller functions, but the same controller action can be called from multiple views, and you can still design the architecture from Model, through Controller (which properties can change under what conditions) and then design the Views (where the interactions can happen).

Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by gf000 on Monday February 16, 2026 @09:26AM (#47035378)
I was asking more in the abstract. Web UI frameworks usually sit on top of considerable abstraction (in the form of the DOM, eventing system, etc), so I'm not sure your reply exactly answers my question.
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by techpression on Sunday February 15, 2026 @05:42PM (#47028495)
Adding to sibling comments, Phoenix. And it’s a damn nice experience at that.
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by namuol on Sunday February 15, 2026 @05:25PM (#47028316)
The deadest horse in web development is the myth of “separation of concerns”
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by IgorPartola on Sunday February 15, 2026 @06:55PM (#47029110)
I was recently doing some very specific web scraping of some very public very static documents. About 25% of them use a soup of divs with hashes for class names. Not a <main> or <article> or <section> in sight. I am fine with the idea of what tailwind does but like at least using semantic tags where appropriate could be a thing.
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by zeroCalories on Sunday February 15, 2026 @09:41PM (#47030292)
Tbh there's nothing really wrong with that. You don't need stuff like article or section if you set the right attributes. Often easier to just use divs to get the structure right, and figure out the meaning later.
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by ordersofmag on Sunday February 15, 2026 @10:18PM (#47030483)
And there's 'nothing wrong' with just writing code with variables named 'a1, a2, a3'. But when some poor sod has to dig through your mess to figure out what you had in mind it turns out that having an easier to discern logical structure to your code (or html) makes it better. I've dug through a lot of html. And there's a ton of ugly code smell out there. Layers and layers of "I don't really know what I'm doing but I guess it looks okay and I'll make it make sense later". I'm sure it pays the bills for someone. But it makes me sad.
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by mhuffman on Sunday February 15, 2026 @10:17PM (#47030480)
Well, it does help if you expect sight impaired people with software to find the site useful.
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by zeroCalories on Monday February 16, 2026 @02:15AM (#47031886)
That's why I said setting the right attributes. You can make a fully featured accessible website using only divs.
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by raincole on Sunday February 15, 2026 @10:36PM (#47030593)
Exactly this.

I wonder if the people downvoted you realize that HN is basically just a big table and a bunch of div, and they use this very site just fine?

Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by dotancohen on Sunday February 15, 2026 @10:48PM (#47030668)
As a user, I don't care.

As a disabled user with a screen reader, I might care.

As a developer tasked with maintaining it after the original dev left, I most certainly would care a great deal.

Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by raincole on Sunday February 15, 2026 @11:32PM (#47030919)
As a developer you maintain the source templates, not the compiled/generated HTML. The HTML is messy doesn't mean the source templates are so.

Semantic web is basically "please think of the crawlers."

Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by xmprt on Sunday February 15, 2026 @11:29PM (#47030904)
Except that as a developer you have access to the original source code where things are well structured. It only turns into div soup after the React/Vue code gets compiled down to HTML+CSS+JS that can run on any browser.
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by zeroCalories on Monday February 16, 2026 @02:34AM (#47032031)
Besides the points raised here, I think it's worth noting that using stuff like the article tag does not necessarily make things easier to maintain. You do indeed get a lower line count, but you're coupling the structure and meaning. Sometimes that's fine, but a11y can be tricky to get right and it's often easier to push it off until you've got something working first.
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by oneeyedpigeon on Monday February 16, 2026 @05:26AM (#47033334)
It's possible to know that HN is basically a big table, use the site just fine, and still recognise that there are disadvantages to that approach.
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by chuckadams on Monday February 16, 2026 @09:48AM (#47035670)
And it's nearly impossible to customize any part of the layout with user styles because of that.
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by akst on Sunday February 15, 2026 @10:56PM (#47030715)
I do sympathise as someone who has to scrape content from time to time, but that doesn't sound like a problem for the author of the content or something that impacts their intended user.
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by luckydata on Monday February 16, 2026 @12:41AM (#47031277)
that's a problem for accessibility too
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by isqueiros on Monday February 16, 2026 @03:22AM (#47032357)
tailwind is very much not a problem for accessibility? if your content is semantic and you add the appropriate aria tags, whether or not you have 300 classes or 1 will make no difference for screen readers
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by UqWBcuFx6NV4r on Monday February 16, 2026 @05:04AM (#47033152)
No, it really isn’t. Use of Tailwind has no bearing on the semantics of your HTML. You’re conflating two completely different things.
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by namuol on Sunday February 15, 2026 @11:21PM (#47030854)
You can grumble at web developers in general for things like div soup, but the hostility towards tailwind is misplaced. Hashed classes aren’t even tailwind, and the tools that generate them are not the problem either.
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by bryanrasmussen on Monday February 16, 2026 @02:25AM (#47031966)
I'm pretty sure unreadable class names are a byproduct, but perhaps some people may also consider it a feature, of their particular build process.

so they may very well have semantic tags in their development environment. Of course debugging things becomes more difficult for the developer as well unless there is some sort of lookup table to tell them that class .uv.le in the browser maps to .user.name in their codebase, in which case it only becomes marginally slower for some cases.

Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by jcgl on Monday February 16, 2026 @05:18AM (#47033261)
That's totally orthogonal to Tailwind though; there's nothing that precludes you from combining semantic elements with it. The only thing that would make a dev reach for <div class="m-2"> instead of <article class="m-2"> is the dev's own (lack of) taste. It's no different than writing out separate CSS or using inline styles.
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by eitau_1 on Monday February 16, 2026 @07:08AM (#47034037)
I'll add that writing userscripts became more challenging b/c of this phenomenon.
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by xnx on Monday February 16, 2026 @07:13AM (#47034075)
Wait until sites start rendering to canvas. You will yearn for the days of div soup.
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by agos on Monday February 16, 2026 @09:50AM (#47035714)
why should they? this has been a worry for some time, but I don't see it happening
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by nonethewiser on Monday February 16, 2026 @10:29AM (#47036236)
It already happened. WASM. And it's generally been used well.
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by kevlened on Monday February 16, 2026 @12:51PM (#47037964)
There's an active proposal for rendering html in canvas to control styling. Text rendering and accessibility are main focuses for the proposal.

https://github.com/WICG/html-in-canvas

Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by jamesfinlayson on Tuesday February 17, 2026 @01:20AM (#47044297)
I thought it was being done for web apps like Google Docs now, and I thought one of Microsoft's cross-platform toolkits used <canvas> too (though I don't think this toolkit itself will see broad adoption).
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by falcor84 on Monday February 16, 2026 @10:37AM (#47036345)
There's also the issue that whatwg pretty much stopped adding new semantic elements; if I'm not mistaken, only <search> and <dialog> were added in the last decade, after the introduction of HTML5. <main>, <section> and <article> are increasingly being overloaded to the point of meaninglessness.

The most cited example of one that's clearly missing is <comment> for user-added content, but there are probably dozens we could add that could help deal with the div soup. By not adding any new elements, whatwg is essentially saying "You're not going to be able to use these the existing tags to fully add proper semantics anyway, so why try?"

Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by burningChrome on Monday February 16, 2026 @12:57PM (#47038028)
Not defending it, but this is most likely a cause of using some enterprise CMS like Adobe AEM which is notorious for doing stuff like this.

Its not right, but a lot of times CMS's are horrifically bad at adding content without a slew of nested, auto-generated <div>'s.

Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by appplication on Sunday February 15, 2026 @05:48PM (#47028556)
You can separate concerns without violating locality of behavior, and that’s exactly what tailwind does.

It admittedly does not do a good job at being very DRY but I think that’s poorly applied to HTML/CSS in general, and the most DRY css is often over abstracted to the point of becoming nigh uninterpretable.

Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by nine_k on Sunday February 15, 2026 @06:02PM (#47028658)
When I write CSS, I most often do not want the locality of behavior. I instead want uniformity of behavior, hence "semantic" styles. Even the trivial light / dark mode switching is pain with Tailwind, when classes like "color-gray-200" are routinely applied.
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by appplication on Sunday February 15, 2026 @06:08PM (#47028706)
I’d somewhat agree with you there, but I usually use variables for uniformity. I do see arguments against tailwind but find anytime I’ve tried to do anything else it just feels like bikeshedding on internals for the same end result.

Really what I want to see is beautiful TDD for CSS so that uniformity can be enforced, but I’m not sure that exists.

Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by nine_k on Sunday February 15, 2026 @06:21PM (#47028811)
Variables are hugely helpful, I agreee. IDK about bikeshedding. I'm very used to writing React code that normally declares no styles for components at all, and having CSS that style components using 1-2 classes, specific to these components. Container components control margins, <body> controls general things like fonts.

It seems that what solves the problem is a good component library. "But I need red text here!" For what reason? It's a warning. OK, we've got <Text variant="warning">, it will be styled appropriately, and will look like every other warning in the application.

Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by zeroCalories on Sunday February 15, 2026 @09:48PM (#47030330)
I tend to think that if you're having issues with repeating yourself with stuff like tailwind you probably need to refactor your JSX/templates to share the repeated code. Keeping stuff like CSS isolated is a deliberate choice that helps massively with stuff like splitting code, and keeping changes side effect free.
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by kristopolous on Sunday February 15, 2026 @08:23PM (#47029774)
It's a choice. The dominant paradigms choose not to.

I disagree. And that makes me the loser here

Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by namuol on Sunday February 15, 2026 @11:23PM (#47030866)
I agree, it’s a choice. So is the opposite. Complaining about other people’s choice of doing things on the web is the choice I’m actually tired of.
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by samastur on Monday February 16, 2026 @07:53AM (#47034388)
Read something else then.
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by namuol on Tuesday February 17, 2026 @11:47PM (#47057277)
I’m a web developer by trade. I read about it. Sorry?
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by samastur on Thursday February 26, 2026 @04:04AM (#47163686)
I am as well and there's no shortage of relevant content to fill my whole day so I can skip articles I dislike.
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by gilcot on Sunday February 15, 2026 @08:53PM (#47029993)
Another loser here to second you
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by kristopolous on Sunday February 15, 2026 @09:05PM (#47030080)
I wrote these libraries like

https://github.com/kristopolous/db.js and https://github.com/kristopolous/evda in the early 2010s. I spent months on them

I was all in. I swore off touching front end in 2022. It's terrible now

Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by noduerme on Sunday February 15, 2026 @09:51PM (#47030343)
Ah, yeah. I spent the early 2010s writing front-ends in AS3, so imagine how that turned out. I wrote my own event system too when I was forced to head to javascript, but in the end I mostly just used jquery's, and it's still what I use. I agree the event-driven paradigm leads to sloppy code, but static event names are enough of a clue to what's invoked most of the time, even in relatively large projects. And most things can sensibly just be promisified now anyway, besides user interactions.

I thought it was funny that you wrote this way back when:

>> I've often seen projects where I think "what talks to what and how? What is the separation of concerns and where does this code live?"

Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by zarzavat on Monday February 16, 2026 @04:25AM (#47032823)
I don't use Tailwind, it's a solution to a problem I don't have.

I can understand how it might be useful for certain types of web development, e.g. landing pages where the content and styles are tightly coupled.

So as a technology, it's OK. But my god its userbase is toxic and obnoxious.

Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by UqWBcuFx6NV4r on Monday February 16, 2026 @05:07AM (#47033184)
Okay. I personally don’t care for anyone so chronically online that they think that their interactions with other similarly chronically online people is at all representative of the userbase of something as immensely widely used as Tailwind.

Whatever the professional equivalent of ‘touching grass’ is, I suggest you do that at your earliest convenience.

What an absurdly absolutist statement.

Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by netdevphoenix on Monday February 16, 2026 @09:45AM (#47035630)
The majority of its userbase is no longer made of humans though.
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by the_other on Monday February 16, 2026 @04:30AM (#47032857)
SoC is how all maintainable software is built. A function for A, a class for B, DDD-spec'd modules and features, databases on separate machines, API definitions, queuing systems, event systems, load balancing, web servers.

You don't even need to think of the web to see how content and presentation are different. Try editing a text file with hard line breaks in and you'll quickly understand how presentation and content are orthogonal.

Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by UqWBcuFx6NV4r on Monday February 16, 2026 @05:09AM (#47033201)
Please don’t be so condescending. We all know what separation of concerns is.

The comment said “web development”, and it’s inarguably that in the history of web development there have been at least a couple of major misapplications of separation of concerns, which have had practically everlasting negative consequences.

Read what you’re replying to before you reply to it.

Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by tgv on Monday February 16, 2026 @05:38AM (#47033437)
I don't think "separation of concerns" is entirely dead. Ideally, the CSS is readable and maintainable, and that implies structure. If you have a bunch of (co-)related components, you don't want to find/replace tailwind class names when you need to change the layout. So you separate that part of the layout in classes based on (layout!) functionality. You can see that as "concerns."
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by namuol on Tuesday February 17, 2026 @02:00AM (#47044511)
Components are the tool you’re looking for. For the rest there’s CSS variables. Soon we may have @mixin.
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by nonethewiser on Monday February 16, 2026 @10:23AM (#47036168)
I can't believe this isnt better understood. Style definitions on reusable components are good. The idea that your css doesn't have to know about your html just creates tons of problems and complexity. Global themes and reusable styled are fine.

If we are talking about statically defined html then sure. make your global css files.

Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by darekkay on Sunday February 15, 2026 @09:05PM (#47030077)
HTML vs. CSS is a separation of technologies. If HTML was really only about the content and the CSS was only about styling, we wouldn't have to write div soups to style our websites (.container-wrapper .container .container-inner { /* "separation" */ }) and we wouldn't have to adjust our HTML when we change the layout.
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by fainpul on Monday February 16, 2026 @02:15AM (#47031885)
> we wouldn't have to adjust our HTML when we change the layout.

You don't have to: https://csszengarden.com/

Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by insin on Monday February 16, 2026 @03:12AM (#47032286)
Fine for a static site which is frozen at the first version forever.

So, so, painful for apps which need to change and evolve over time, which I'm currently experiencing. It's too easy to break the bits where you needed to get clever to make a layout variant work.

I did also did a Zen Garden on YouTube recently when they removed the list view option from Subscriptions, restyling their grid markup was a fun CSS exercise.

Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by ruszki on Monday February 16, 2026 @02:45AM (#47032096)
But for that designers should care about the limitations. But they don’t care. Not even about the more basic ones. I’m quite sure many of them don’t even know. Mainly, because their customers are not the one who code.

I got many designs for websites where customers told me that they want a pixel perfect version. The funniest one was when my boss who supposed to be a “senior” web developer told me this. Of course, there is no such thing on the web or really anywhere. Actually, I’ve never seen a design plan in which wildly different aspect ratios and sizes were really considered.

Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by zelphirkalt on Monday February 16, 2026 @05:03AM (#47033137)
This doesn't solve the problem but:

If the designer is not aware of the ins and outs of the medium they are supposedly working with, they are not a very well informed and educated designer.

Just like I don't presume to be able to make a great product packaging design, without knowing firstly much more about visual composition and design, but also secondly the material and form and shape I am designing for. Will that be a plastic wrapper, a paper wrapper or some cardboard packaging? Without knowing the limitations and properties of each, how can I expect to create a good design?

Being that uninformed to me seems like not giving a shit about the quality of work one delivers, ergo not giving a shit about ones job, or simply not having the required understanding or skill to be any good at ones job.

Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by ruszki on Monday February 16, 2026 @08:47AM (#47034877)
> not giving a shit about the quality of work one delivers

I’ve learned in the past decades that people who care about quality is the minority.

Look at any B2B software. They don’t care because their customers are different than who uses their products. They care about their customers only (managers). They pay attention to users as much as minimally possible without loosing customers.

This happens at every level.

Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by troupo on Monday February 16, 2026 @02:38AM (#47032048)
And if you read the CSS there, it's an unmaintainable mess of absolutely positioned elements
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by easyThrowaway on Monday February 16, 2026 @02:47PM (#47039380)
CSS Zen Garden is quite the opposite of a good example of your point. Even small changes to the original page layout would completely break most of the provided styles.

If I removed the .page-wrapper class it would be also nearly impossible for a different developer to reverse-engineer the issue from the existing Template and CSS files.

Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by shimman on Monday February 16, 2026 @10:23PM (#47043351)
Yes, if you remove CSS it does tend to break the CSS.
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by easyThrowaway on Tuesday February 17, 2026 @05:31AM (#47045824)
The point isn't simply "class removal affects cascading", but "anything upstream is capable of placing the original content in an unrecoverable state".

Where "anything" could be your framework, your CMS, you or your coworkers a few years after the original CSS has been written and you can't fully remember what ".format-header__nav-wrapper:not(:last-child) .model-header__nav-wrapper:not(:last-child)" is doing.

And yes, that's a real CSS selector from a refactoring job I'm doing right now.

Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by WorldMaker on Monday February 16, 2026 @10:49AM (#47036509)
I find that most div soup is going away with CSS Grid. CSS Grid is often best when you lose wrappers and nesting. subgrid and display: contents help pop layers when you can't touch the HTML nesting, but now a lot of nesting feels unnecessary in the first place.
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by pjmlp on Tuesday February 17, 2026 @03:17AM (#47044940)
We only have to write div soups to style our websites, because people keep misuing a platform for interactive documents for an OS abstraction.
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by Sateeshm on Sunday February 15, 2026 @09:16PM (#47030140)
Tailwind is not what you're describing.
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by digitalPhonix on Sunday February 15, 2026 @09:19PM (#47030160)
Isn’t that what utility classes are? Shorthand for inline styles?

Not saying it’s good/bad, but it feels like that’s the use case

Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by francislavoie on Monday February 16, 2026 @12:52AM (#47031329)
It's much more than that because it can make use of CSS pseudo selectors like hover, which is not possible with inline styles.
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by rafark on Monday February 16, 2026 @12:23PM (#47037649)
Under that definition any css class is a shorthand for inline styles
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by digitalPhonix on Tuesday February 17, 2026 @02:31AM (#47044688)
There's a big difference between utility classes which are shorthand for inline styles (random example from Tailwind's site where every single class is a one-to-one mapping with a single style override.):

    class="ml-3 hidden rounded-lg bg-gray-100 px-2 py-0.5 text-xs/6 font-semibold whitespace-nowrap text-gray-700 lg:block dark:bg-gray-400/15 dark:text-gray-300"

and semantic names which use the CSS cascade:

    class="main-content subheading"
Calling that a shorthand for inline styles is just being obtuse.
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by Sateeshm on Monday February 16, 2026 @12:41PM (#47037862)
Media queries, pseudo selectors, extensible design system with sensible and practical defaults, and many more
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by raincole on Sunday February 15, 2026 @10:24PM (#47030520)
Yeah and it's a really good idea. You can't really 'separate layout from style.' The layout and the style are both parts of the UI. HTML isn't the content, it's the layout.

Even if you believe separation of concerns is the eleventh commandment, HTML and CSS are the same kind of 'concern' anyway. They're both at representation layer. Pretending you can decouple them is just burying the head in the sand.

Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by Sateeshm on Monday February 16, 2026 @12:43PM (#47037885)
Thank you. This just makes sense. In fact, seperating them into different files don't make much sense when you think about it.
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by nilslindemann on Sunday February 15, 2026 @11:07PM (#47030780)
Yeah. There is no need to obfuscate your code, just use Tailwind.
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by namuol on Sunday February 15, 2026 @11:27PM (#47030886)
Obfuscate? I can learn tailwind and use it in dozens of projects. I can use tailwind in my project and onboard dozens of developers immediately. I can learn your CSS conventions and use them in exactly one project.
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by nilslindemann on Monday February 16, 2026 @12:06AM (#47031103)
Why can you use CSS conventions in only one project?
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by manuelmoreale on Monday February 16, 2026 @02:07AM (#47031813)
He wrote "learn your CSS conventions" which implies that every team and every project will have a different set of conventions. Hidden inside that statement is the fact that he just accepted that Tailwind should be THE CSS convention, something I personally disagree with but to each their own.
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by namuol on Tuesday February 17, 2026 @01:57AM (#47044489)
No. Tailwind is a way of writing css, not a convention. By “your” convention I’m referring to the problems with the cascade, ie naming classes and so on. I’m not saying tailwind is the only other way. There are many ways to write CSS but doing it with something bespoke for your situation is usually a bad idea.
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by UqWBcuFx6NV4r on Monday February 16, 2026 @05:12AM (#47033214)
Can we all just drop words out of comments that we reply to if it makes it easier to make our point?
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by namuol on Tuesday February 17, 2026 @01:58AM (#47044492)
You can try to rely on conventions across projects, sure. It doesn’t work well.
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by sylario on Monday February 16, 2026 @05:06AM (#47033172)
I do not work frontend and yet, I always end up having to do some CSS here and there.

I have never been happy on how I manage CSS. With tailwind, I am still unhappy about my styles but I can make my ugly UIs faster.

Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by mb2100 on Monday February 16, 2026 @05:43AM (#47033472)
If everything in your code is a React component, I get why you would just want to write the styles right there.[0] Then again, why write `<Button>` if you could just write `<button>` and style it with standard CSS.

[0]: https://mastrojs.github.io/blog/2025-11-27-why-not-just-use-...

Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by rafark on Monday February 16, 2026 @12:19PM (#47037609)
Because button is literally anything clickable. Not everything is a boxed button. You cannot just globally add a style to <buttton> and call it a day. For example, an upvote (^) button, a close (x) button, etc. A lot of clickable elements aren’t inside a [click me] box
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by mb2100 on Monday February 16, 2026 @03:30PM (#47039920)
button, .button { /* my button styles */ }
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by skeptic_ai on Monday February 16, 2026 @03:02PM (#47039570)
What if you need 3 levels of html tags?
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by ggregoire on Monday February 16, 2026 @03:03PM (#47039577)
> If everything in your code is a React component, I get why you would just want to write the styles right there.

Even for keeping the style close to the component, you can just use standard css.

Create a folder Button, create two files Button.tsx and Button.css in that folder, import the css file in the tsx file, add a class "button" on the first element the tsx file renders, start all the rules in the css file with ".button " to encapsulate the style.

People will say it's too much work, but it took me like 5 sec.

Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by mb2100 on Monday February 16, 2026 @03:32PM (#47039940)
if you're not using CSS modules, why would you import the css file into your javascript? But anyway, I think we agree. Feel free to read the linked blog post ;-)
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by ggregoire on Monday February 16, 2026 @03:36PM (#47039995)
Yes we agree, my comment was for tailwind users. :) I was replying to you because you gave the example of a Button component, and it's a good example to demonstrate that you don't need tailwind to style components.
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by skeptic_ai on Monday February 16, 2026 @06:44AM (#47033877)
That’s separation of technology not concerns. The concern is the component itself.
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by peacebeard on Monday February 16, 2026 @02:44PM (#47039347)
Well put.
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by rafael-lua on Monday February 16, 2026 @07:07AM (#47034028)
Are we still complaining about Tailwind? This ship has sailed. The world is so much better than the old BEM/LESS hell, it is wonderful. UnoCSS is even greater in empowering frontend developers.
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by AltruisticGapHN on Monday February 16, 2026 @09:24AM (#47035334)
BEM is actually not hell, since the whole point is to have classes with a specificity of 1, making precedence of CSS rules easy to figure out.

Non-BEM CSS with ids and multi-classes everywhere was hell.

Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by exodust on Saturday February 21, 2026 @03:33AM (#47098709)
Agreed. I owe a beer to whoever thought of BEM. It's saved precious brain cycles thinking of names. At first I was like what is this bem__opinion--rubbish but then it clicked and my workflow improved.
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by chasd00 on Monday February 16, 2026 @09:48AM (#47035674)
If I may be so bold, the coding agents are really good at this stuff. Save yourself the pain of front end and make a clanker do it. Or at least make the clanker to the heavy lifting and just do tweaks yourself.
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by abustamam on Monday February 16, 2026 @11:11AM (#47036803)
Having worked on teams that wrote bad (S)CSS and teams that wrote bad tailwind, I prefer bad tailwind.

With tailwind, I can guarantee that changing a style in one component will only change that component. With css, there is no such guarantee. So of course the (wrong) way many devs fix it that is to add a new class, probably doubly specific, sometimes with important, and then everyone is sad.

Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by rafark on Monday February 16, 2026 @12:09PM (#47037508)
And thank god (or Adam) for that. Tailwind makes me much more productive.
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by cush on Monday February 16, 2026 @12:45PM (#47037908)
Separation of formatting/representation was invented? Where was I?
Re:Modern CSS Code Snippets: Stop writing CSS like it's 2015 by saidinesh5 on Monday February 16, 2026 @02:28PM (#47039186)
It really depends on the websites no?

If you're building a "webapp" where you think in terms of components, no point keeping the style sheet separate..

If you're building a "website" which is basically a list of hyperlinked documents with the same styling, having just one style sheet would make sense...

Of course, there's a lot of gray area in between the two...

At the end of the day, the most that most of us can really do is be annoyed at the quirks of these leaky abstractions in the large codebases that's thrust upon us.