News for hackers. Stuff that matters.
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.