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
Jach#
Your frontend experience sounds like you've only dealt with web apps. Try making more web sites. That is, collections of pages that have enough content on them to scroll. Don't use any framework, don't even use JS if you can help it -- maybe something like PHP is ok to avoid some repetition (i.e. just use it for require_once of shared html). Then you'll understand the environment CSS was forged in. Ctrl+F the comments here for "box model" for the main "make it click" piece. (Edit: you might even want to try designing without CSS, to see what that's like. It's actually not that bad, and may well remind you of how things are typically done in frameworks these days -- a regression IMO, but a reminder that separation of design from markup isn't truly necessary.)
bellerose#
CSS isn’t bad after writing it a lot and googling the same tricks to do what typically works. My best advice is to stick to some framework for most UI (material or bootstrap) with using custom css seldom. Colors are definitely an art form and matter a lot.
alan_n#
Those are two different problems, imo, one is you don't know the language, and the other is design. I'm an artist and I've always understood design (not to say I was great at it, it still took experience, but I can see a site and I can understand why it does/doesn't work visually), so I can't speak much about how to learn it, except to first try to copy/observe from designs you think are good and go from their.

As for css. I actually like designing UIs from scratch so it's not like I hate it when I'm doing it, but it's bad. It's like 80% works as intended, but then there's 20% that is just weird quirks and there's no way around them but to memorize them. For example, I just ran into a particularly annoying one again recently (you can't do overflow-x: hidden with overflow-y:visible). This stuff is not going to change. At best they might add some new property to fix it. And the workarounds are often dirty.
I would suggest, A) keep a list of problems you run into and their solutions if they're particularly weird, even better, make fiddles of the solutions, and B) comment your css with why you did what when it's out of the ordinary. Sometimes you'll need to create extra wrapper divs, etc, and when you come back to a project after some time you'll have no idea why they're there or why you placed some weird css property, C) master flexboxes and grids and know their limits, that will get you 90% there usually.
Also using something like scss or less, or currently I'm trying styled components (css-in-js <- though it doesn't feel like it), really helps.
As for how related learning css and learning design are, I'd say, you do not need to know design to know how to use css, but you need to know css to be able to implement a design. You can get by without knowing design (there's plenty of css frameworks), but frameworks won't save you when you need to tweak them with css. Also you can practice design without knowing css (e.g. using photoshop or figma or something), although note many times nice designs are nightmares to implement in css, which is why I think learning css is more important.

Load more comments