Ask HN: Is it just me, or is CSS too damn hard?
499 pointsI'm a seasoned backend developer and systems administrator, with over 10 years of full-time programming experience. I've worked with anything from Assembly, C, Rust all the way to Python, Erlang, Elixir, PHP, Haskell, Lisp, Clojure.
When it comes to frontend, I have used React, Vue.js, ReasonML, Clojurescript and Elm extensively, and I know my way around web technologies in general. However, ever since I first started programming, I was NEVER able to get the gist behind CSS. I can't center my divs properly. I can't say "hey, CSS, this is the parent div, and all child divs must obey its size". I can't do anything basic on CSS without turning for help.
Incidentally, but very likely related, I always failed to have any glimpse into how design works. I have no idea which colors "go" with which ones, and pretty much all fonts look like the same for me.
I'd like to know the experience from fellow programmers. Is CSS an "art" thing? Is it common for other developers to have issues with it, or is it just me? Is there any material out there that made CSS "click" for you?
Comments (340) 150 threads
Show all comments
Showing thread 24 of 150
Understanding the DOM, the CSS box model (and more recently, flexbox), and the above-mentioned nuance if you're coming from the app world, is more relevant than ever in our mobile-first time and age. Until you wrap your head around the notion that no, you're not styling an app screen that is fixed-sized, but are rather styling a document, you'll find CSS hard. (And yes, the real WTF is why are we using this type of tech to build UIs instead of native controls, but that's another debate.)
Once you do grok that, you also need to learn to accept some quirkiness and imperfection (it is a lousy language, after all, and browser engines don't render everything the same way), and you'll find that CSS is not that hard.
This seems to be true of many devs who find CSS hard - there seems to be an assumption that you can take any HTML structure and use CSS to magically make it look like any design. The author of the question even lists a huge number of languages they've used over 10 years but misses out HTML as one of them. The simple fact is you can't just use CSS. To implement specific layouts you also need the right DOM structure.
Not only that but you are building a page that displays on all kinds of screen sizes so you just have no idea how much space there is between here and there. Thats 90% of what makes CSS hard because depending on what screen you are on, you can't just put something here because here doesn't exist for everyone.
I think CSS is designed fairly well its just that its solving a very complex problem of how do you make one page display on all kinds of devices without having to define layouts for them all.