Lurker News
Hey HN,

I'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

Earlier comments
temporallobe#
I’ve been working with CSS for about 20 years now and it still baffles me at times. I understand selectors just fine and I’ve memorized most rules, but placement and spacing are still unintuitive in my opinion, not to mention all tbe browser-specific rules and overrides. Oh yeah and there are plenty of young devs who don’t understand that SCSS generates CSS and don’t understand actual CSS. It also doesn’t help that so many libraries and frameworks encapsulate all the CSS heavy-lifting for you, never forcing you to actually have to learn CSS, which is in fact hard.
whooaaaa#
You really want to develop a mental model of a CSS engine, so you can “run” code in your head.

This will allow you to read code and have a high chance of predicting what it will look like before running it.
Your probably not developing this mental model for some reason.
You should try to explain why you are seeing a visual result, and keep a notebook of how CSS primitives work together. For example, why are there 10 ways to vertically align, and why do they all work?
Once you collect enough primitives, you can use them together to design a layout.
You could try developing your own css layout engine which would force you to understand the rules.

whytaka1 reply#
I am a designer turned developer. But long before entering development, I made websites with HTML and CSS from scratch.

I have no idea why people find CSS difficult. There is the odd case which even I find cumbersome, but for most of UI development, I find creating layouts with it very natural.
If you have specific questions, I can probably help.

whalesalad#
Same exact experience. I have a few theories as to why some struggle. One, I think of myself as having really great spatial awareness and reasoning abilities. I can think of a div in 2D space and imagine all of the forces acting on it to push it around. I’m a very visual person and tend to do well with stuff like this. Contrast this to complicated recursive algorithms and I can’t do it without actually drawing it with shapes and physical things. So I think of this as the proverbial right brained or left brained... some are able to visualize things better in their mind and I think those people tend to grok css better.

Two, I think all of the modern tooling and libraries have stunted folks abilities to learn the fundamentals. There’s also been a paradigm shift in that, at one point, there was a much more distinctive line in the sand between frontend and backend where it was more typical to build a website that was either static or used a CMS and you spent 90% of your time living in HTML/CSS... so you could master it better. Nowadays if you find the latest tutorial or join a boot camp or whathaveyou you’re gonna a be messing with components and css-in-js, express servers, graphql etc... so it’s a lot harder for a newb to hone that skill.
If you wanna know and be good at CSS you need to go back to basics and actually learn it. Text editor, style.css, index.html and a browser window.

oliwarner#
I guess I'm alone in liking CSS.

Yes, it definitely takes years of experience implementing annoying designs to appreciate... But the macro-positioning stuff comes pretty easy once you understand the box model and can visualise the positioning.
I don't think it's an art. It just takes real experience.

Load more comments