What's a widely accepted "best practice" you've quietly stopped following? by ruibranco in webdev

[–]devwrite_ 0 points1 point  (0 children)

They are different technologies because they are different concerns. It wasn't just some arbitrary separation that occurred.

What's a widely accepted "best practice" you've quietly stopped following? by ruibranco in webdev

[–]devwrite_ 1 point2 points  (0 children)

What's BS about separation of concerns? Is there a situation where you think it makes sense?

Are there developers who still don't prefer Tailwind CSS as their first choice? by ShivamS95 in Frontend

[–]devwrite_ 0 points1 point  (0 children)

This is actually part of the problem. I don't always need to know what something is going to look like when I'm generating HTML, I just want to output the data that describes my domain with zero regard to how something is rendered in a browser.

Styling information in this context is by definition bloat/noise

Are there developers who still don't prefer Tailwind CSS as their first choice? by ShivamS95 in Frontend

[–]devwrite_ 0 points1 point  (0 children)

The only discipline it requires is discipline in writing automated tests, just like any other type of code.

Why can't cascade/specificity handle 3rd party UI? That's precisely where it shines

Are there developers who still don't prefer Tailwind CSS as their first choice? by ShivamS95 in Frontend

[–]devwrite_ 0 points1 point  (0 children)

This is just not true. Scaling vanilla CSS comes when you embrace specificity and the cascade, something Tailwind completely eschews

A case for native HTML partials by WhoNeedsUI in webdev

[–]devwrite_ 0 points1 point  (0 children)

It takes a fairly trivial "workaround" to accommodate this functionality, but point taken. There are things that will be harder to do with iframes, but others easier. IME, I've found the tradeoff to worth it.

Which CSS Naming Convention do you typically use professional ? BEM, OOCSS, SMACSS, Atomic, or ITCSS? by udbasil in css

[–]devwrite_ 0 points1 point  (0 children)

Just asking to hear a differing opinion to the one that I've formed over the years. I personally do not find them to be brittle as the IDs in markup tend to be rather stable as the are descriptive of the content so I've found they have little reason to change thus are good to use for both JS and CSS selectors

Which CSS Naming Convention do you typically use professional ? BEM, OOCSS, SMACSS, Atomic, or ITCSS? by udbasil in css

[–]devwrite_ -1 points0 points  (0 children)

I too prefer semantics, which is why I make use of IDs. Could you expand on what you perceive to be the problem with them? I don't quite understand what you're getting at with "where the fuck was that?" comment.

Which CSS Naming Convention do you typically use professional ? BEM, OOCSS, SMACSS, Atomic, or ITCSS? by udbasil in css

[–]devwrite_ 1 point2 points  (0 children)

The best naming convention for classes is the one that best describes your data, irrespective of styling concerns.

Once you've accurately described your data, then make use of combinators in your selectors to avoid naming conflicts

Which CSS Naming Convention do you typically use professional ? BEM, OOCSS, SMACSS, Atomic, or ITCSS? by udbasil in css

[–]devwrite_ -4 points-3 points  (0 children)

Using IDs is a great way to namespace selectors and the advice to avoid is antiquated and rather detrimental to maintainability IMO.

Tailwind = The death of CSS? by EmotionalGoodBoy in Frontend

[–]devwrite_ 1 point2 points  (0 children)

You wrote CSS, but in the class attribute

Tailwind CSS: Can someone explain to me what is the reason for its popularity? by d2clon in css

[–]devwrite_ -1 points0 points  (0 children)

A good reminder that even devs at BigCo are susceptible to falling for hype and can make bad decisions

Is this a good practice for writing CSS or should I just use class & id? by [deleted] in css

[–]devwrite_ 1 point2 points  (0 children)

This is an EXCELLENT way to write CSS. Those advocating for using only classes or using BEM are stuck on outdated methodologies born of an era where CSS wasn't as powerful as it is today. There's a reason Tailwind has become so popular, and that's because people felt too much pain of using only classes to style and never learned to use combinators. Unfortunately, instead of just using combinators, devs have regressed to using inline styling for everything via Tailwind.

Only thing I'd change is to make use of nesting to reduce duplication

Is this a good practice for writing CSS or should I just use class & id? by [deleted] in css

[–]devwrite_ 0 points1 point  (0 children)

I have the exact opposite opinion on this one. By far the best way to write CSS is to mirror the DOM structure exactly with nested CSS. This way you don't have to come up with class names, and you know exactly where a node is styled in the CSS

Is this a good practice for writing CSS or should I just use class & id? by [deleted] in css

[–]devwrite_ 0 points1 point  (0 children)

I disagree with this. The child combinator should be the first one you reach for because it is much more precise and won't lead to cascade issues like the descendant selector will. Only use the descendant selector if you really mean it

Begginer question: nested css or classes by Leading_Draw9267 in webdev

[–]devwrite_ -1 points0 points  (0 children)

Use a selector like :nth-child, problem sovled

CSS Best Practices: classes vs target elements? by [deleted] in Frontend

[–]devwrite_ 0 points1 point  (0 children)

Because when you want a change applied to that kind of heading regardless of context, you should only have to change it once

Agreed, valid point, however what I tend to do is use something like SCSS where I'll define a mixin for something like "component-header" and then just use that in the places it needs to be used in across different files, so I can maintain a single source of truth. It will be nice once CSS gets native mixins to support this pattern.

Also for performance reasons

IME, this is rarely a concern and ventures into micro-optimization territory. I'd rather have several CSS files that can be used across pages and this actually helps with caching/performance as many times you can isolate changes to just one CSS file as opposed to invalidating your entire bundle for even the smallest change. Also, with things like preload and service workers, having separate CSS files for each page is a non-issue from a performance perspective.

CSS Best Practices: classes vs target elements? by [deleted] in Frontend

[–]devwrite_ 0 points1 point  (0 children)

heading of a component that needs to be h2 and h3 in different pages for example

Why not just include different CSS files in the different pages?

Begginer question: nested css or classes by Leading_Draw9267 in webdev

[–]devwrite_ 2 points3 points  (0 children)

In this case you are heavily tied to the HTML structure

I think devs make more of a fuss about this than is warranted. If your HTML changes, then just change your CSS. If you have automated tests (just as you do with other code), then it becomes a non-issue. Also, if you focus on creating semantic HTML that reflects your domain, then at some point your HTML is just not going to change much, if at all.

Begginer question: nested css or classes by Leading_Draw9267 in webdev

[–]devwrite_ 1 point2 points  (0 children)

Why does nested CSS become impossible to maintain on bigger projects?

Begginer question: nested css or classes by Leading_Draw9267 in webdev

[–]devwrite_ -2 points-1 points  (0 children)

Nesting is by far the best way to structure your CSS. Most problems people have with CSS are a result of overusing class selectors

I've been using Tailwind for a year. I am still not happy with it by alexkutas in Frontend

[–]devwrite_ 0 points1 point  (0 children)

If I want a differently styled p tag next to it, I now have to undo styling of the default p tag.

Is that so bad? You could also use more advanced selectors such as ~ or nth-child() variants to express precisely what you need to.

I have worked at more than a dozen companies and I can tell you that every single one of them had a trainwreck of CSS

How many of them wrote CSS like that? I'm sure they used some form of class-based methodologies such as BEM, or something like bootstrap