Live data from Hacker News

Modern CSS Code Snippets: Stop writing CSS like it's 2015

modern-css.com

241–250 of 318 posts

Re: Modern CSS Code Snippets: Stop writing CSS like it's 2015

#241
post #231
post #217

Earlier quoted context omitted.

Wait until sites start rendering to canvas. You will yearn for the days of div soup.

why should they? this has been a worry for some time, but I don't see it happening

It already happened. WASM. And it's generally been used well.

Re: Modern CSS Code Snippets: Stop writing CSS like it's 2015

#242
post #194

I hate how it's still not possible to properly style the numbers in ordered lists. I use them for code snippets with automatic line numbers, but it's literally impossible to space the numbers (relative to the code) while keeping them aligned to the right. ¯\_(ツ)_/¯ https://jsfiddle.net/89t1rd2u/

Try ::before and css-counters.

::before has the same problem. You can't align text inside `content:` to the right. Probably because each ::before is handled separately and can't see the sibling's content length.

Re: Modern CSS Code Snippets: Stop writing CSS like it's 2015

#243
post #232
post #211

Earlier quoted context omitted.

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.

From Tailwind's home page: [...] "immediately" is a stretch

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

#244
post #43

Earlier quoted context omitted.

The deadest horse in web development is the myth of “separation of concerns”

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 or or 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.

There's also the issue that whatwg pretty much stopped adding new semantic elements; if I'm not mistaken, only and were added in the last decade, after the introduction of HTML5. , and are increasingly being overloaded to the point of meaninglessness.

The most cited example of one that's clearly missing is 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

#246
post #4

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.

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.

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

#247
post #243
post #232

Earlier quoted context omitted.

From Tailwind's home page: [...] "immediately" is a stretch

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.

dealing with the cascade and tailwind are not the only two options

Re: Modern CSS Code Snippets: Stop writing CSS like it's 2015

#249

Earlier quoted context omitted.

Tailwind is a direct response to how the "C" in "CSS" actually sucks, so there's no surprise that it's so popular.

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. ---…

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

#250
post #4

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.

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.

Post reply on HN