DEV Community


Discussion on: Styling vs Scripting. Which one is the hardest to learn/control?

leob profile image
leob • Edited

Javascript is "imperative" - they're instructions - "first do this, then do that". If you know the principles of programming, then the basics of Javascript are pretty easy - and easy to reason about, for the average programmer.

CSS however is "declarative", not imperative - you state or "declare" the result that you want. If you do that wrong then the result will not be as you want it, but it's often hard to find out why - you can't simply debug it like you would debug Javascript.

On top of that what makes CSS 'hard' is that there are often many ways to accomplish the same thing - for instance layout (with float, or with flexbox, or with CSS grid).

One explanation for these "redundancies" is that CSS has a lot of historical baggage - it wasn't originally designed as a layout or styling mechanism for our modern day apps, rather it was designed for styling static content-focused websites, so a lot of features were tacked on later to make it work better for modern day "apps".

So, CSS is not only less intuitive/accessible for the average programmer (it's not a programming language), but it's also huge (looking at the scope and the number of features).

dennisfrijlink profile image
Dennis Frijlink Author

Thanks for sharing your mind! Yess CSS indeed has a lot of ways of doing the same thing which makes it complex at the same time. Beside that I never thought about the fact you can't debug CSS, simply because of the fact it's not a programming language.