4 ms·
I've known those things listed for 15 years now, and they did not help with the wack-a-mole problem. Especially not when working with multiple people. The only
by locallost 5y ago
I've known those things listed for 15 years now, and they did not help with the wack-a-mole problem. Especially not when working with multiple people.
The only thing I've found to actually work is to keep things as simple as possible when it comes to your actual stylesheet. Any kind of complexity including some core CSS properties (e.g. the C for cascading) I avoid. My second box .foo is only slightly different so I will adapt it based on its parent .bar leads to misery. Eventually you will need .baz .bar .foo. Or .bar .foo:not(.shoot-me) and all of that will be burried in 100+K of code done by people that left the project 2 years ago. Hence wack-a-mole. So I try to do myself a favor and just avoid any kind of CSS logic. The complexity will be moved to the template, so not really gone, but at least you can make a change and not worry about something else breaking. And at the very least, if it gets complicated, you can write a test to check if your html code contains proper classes.
- themodelplumber 5y agoI'm baffled that you were able to serve up such an eloquent slice of pain without even mentioning !important?
- routerl 5y agoI'm impressed by the phrase "eloquent slice of pain", and have felt the !important pain. Thanks for the catharsis.
- city41 5y agoI've also found atomic css, such as Tailwind, largely eliminates this problem. Yeah, a controversial opinion, but regardless of how you feel about utility classes, they do avoid this problem.
- steve_adams_86 5y agoI used to be a bit of a CSS purist and I thought things like tailwind created a mess where some thoughtful and strategic thinking could prevent it. In reality, preventing the mess costs a lot of time and energy. I'd rather have ugly markup and get things done than have nice CSS. Our users don't give a single shit how nice our CSS is. I'm on a team of 4 competent people who touch front end code, and despite our experience with it CSS is more of a recurring pain than anything else. We plan to make a slow migration to tailwind, essentially building new things with it and keeping our bespoke CSS in maintenance mode until it's replaced or retired. I'm looking forward to our ugly markup.
- city41 5y agoI felt similarly before Tailwind. I now put it pretty close to TypeScript on things I don't want to work without. I think Adam's quote on the front page of tailwindcss.com is spot on "...but the truth is you’re never going to believe me until you actually try it. If you can suppress the urge to retch long enough to give it a chance, I really think you'll wonder how you ever worked with CSS any other way"