loading...

re: Reasons developers avoid CSS VIEW POST

TOP OF THREAD FULL DISCUSSION
re: The reason I don't like CSS is because (strictly as a programming language) there are a lot of things that make it difficult to reason about and to...
 

Thanks Brian, you make some great arguments.

  1. Namespacing and specificity are certainly challenges which need to be addressed in some way. I think there are certain rules that should be followed in larger teams to avoid these issues like BEM, avoid using !important etc. The specific issue of scope and encapsulation being present in other languages doesn't make it impossible to abuse in those languages, as programmers we just follow rules like keeping functions small and avoiding making too much public.

  2. I haven't encountered many issues with layers though I understand the frustration. Complex layering is not intuitive with CSS and perhaps it's something that needs to be addressed. In modern CSS, I will often favour CSS grids to overlap layers effectively. I also follow a simple rule, HTML is rendered top to bottom and any 'layers' will be rendered back to front. The z-index is something to be used sparingly as there is often a way to achieve the same effect another way.

  3. Although there is no 'breakpoint' like functionality in CSS, I think browsers have done an excellent job of providing great tools for debugging. It's improved significantly in the past decade.

The developer console in Firefox 69.0 showing CSS rules
Using the developer console in any modern desktop browser will show which rules are contributing to the final output and where they are coming from. (This screenshot was taken on Firefox inspecting dev.to)

You make some solid points as to why CSS isn't the easiest to reason about. What are some systems of design you find more comfortable to work with out side of the context of web development?

code of conduct - report abuse