The first example of not using absolute positioning isn't a good example because sometimes you do need to absolutely position things, like a modal. Also you can just use display: flex with justify-content: center and align-items: center for non absolutely positioned elements. Just because it uses CSS grid does not make it more "correct" than flexbox. I also only see one usage of custom @property properties here, whic…
Modern CSS Code Snippets: Stop writing CSS like it's 2015
171–180 of 318 posts
Re: Modern CSS Code Snippets: Stop writing CSS like it's 2015
#172Earlier 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. ---…
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
#173Re: Modern CSS Code Snippets: Stop writing CSS like it's 2015
#174Earlier quoted context omitted.
First widely available one I saw was this: https://modern-css.com/staggered-animations-without-nth-chil... That would actually fix some ugly CSS I have. The demo works. Neat. Except... the demo doesn't use either the old syntax or the new syntax. The browser support is wrong (Firefox doesn't support it, the site says Firefox 16+; it says Chrome 43+ but in reality it's much newer: Chrome 148+). It says "Since 2018" bu…
Yeah a lot of these demos say the features are widely available, but they don't actually work in my browser (Firefox on Macos). Makes me wonder if these demos (or the browser support tables) were made by LLMs. They clearly haven't tested the demos in firefox.
My personal trigger events were when Firefox didn't optimize DataView for the longest time, initially refused to implement import maps, and couldn't get WebGPU support done. At that point I lost interest in supporting it.
Re: Modern CSS Code Snippets: Stop writing CSS like it's 2015
#175Me: cool, let's be creative, I love 2026. Browsers: Yeah, but beware of limited availability, most of those creative examples are in the 40-50% browsers support range.
In the past this was a major issue that meant useful features were only ever usable after IE/Safari finally supported them half a decade later, but it has seriously gotten better. Sadly as a result of Chromium's overbearing presence, but it's a helpful outcome at least. https://wpt.fyi/interop-2025
Re: Modern CSS Code Snippets: Stop writing CSS like it's 2015
#176CSS 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.
The deadest horse in web development is the myth of “separation of concerns”
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
#177CSS 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.
The deadest horse in web development is the myth of “separation of concerns”
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
#178Earlier 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. ---…
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 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
#179Earlier quoted context omitted.
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.…
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 - be…
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
#180Earlier quoted context omitted.
Is jumping between files supposed to be difficult or something?
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 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. Wi…