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
amoitnga#
Being able to produce nice, competent design requires a very different skill set from the one developer has. It's not our job to know what are complementary colors, what is hierarchy etc. But when handed sketch/photoshop design it's part of my job to implement it.

It's not a coincidence that you brought up positioning.
> I can't center my divs properly.
I remember having a similar feeling. What made it click for me was searching for some articles like "how to master css".
Btw, just did that search and this is the article I remember I went over https://designshack.net/articles/css/5-steps-to-drastically-..., which is the first result.
Understanding how to position things I think was the biggest aha moment: floats, box model, the difference between positions such as fixed, static, absolute etc...
I think if you go over resources mentioned in that article you'll be good enough.
It feels like there is this idea that CSS is very simple, not a real thing, so we don't dedicate the time to learn it. You wouldn't expect to be good with React after one day, would you? It takes time to learn js, having that base it's easy to pick up React in a few days. And then you read articles on best practices, staying up to date with new versions etc.
CSS requires much less, but still some time and effort. Treat it as technology, give few days, don't skip steps, just sit down and learn it.
You can't solve `x + 5 = 10` when you don't know what `2 + 2 = ?`
So don't try "hey, CSS, this is the parent div, and all child divs must obey its size" until you know what is the difference between absolute and relative position.

ivanhoe#
I don't think CSS has anything to do with art, you usually have the design done already, you just need to put it together in a way that browsers can read, so it's just good ol' programming. Thing is that it's very easy to do a little things and tweaks in css, copy & paste snippets, so people jump to conclusions about css being easy - but then you discover that to really master css it requires a lot of lateral thinking and being able to look at the design and "see the matrix" behind it. It's like trying to figure out haskell and you come from C, you need some time for your brain to rewire how you think of problems. IMHO emphasis should be especially at a lot of learning by doing it, because experience is everything with css. So just give yourself some time, work on it and you'll figure it out...
zoomablemind1 reply#
My feeling about CSS is similar to asm/Assembler. It gives you ultimate handles, but it's very much low-level down to pixels. Same about peculiarities of the underlying platforms and browsers.

While I see great uses for asm directly within parts of an application constructed with higher-level languages, yet building a whole system using asm is unnecessary. Compiler does this job.
With CSS from scratch or not, you need to move, store, add, clear, and jump on your own. And let's not think of how many losely coupled variables a real-life web-design presents to deal with. There's no compiler for this, only a debugger (Firebug, etc.) CSS frameworks simplify some aspects of this, but fundamentally it's still low-level.
That's what makes this CSS chase a somewhat futile exercise in a long run. Assembler is at least is more concise to memorize.

kevintb#
This is a great way of putting it.
Androider#
It's easy-peasy once you get the general algorithm down:

1. Is there a Stack Overflow CSS snippet you can use as-is that solves your problem? Score!
2. No? Fiddle with random bits until it looks OK in your browser of choice (Chrome). Display: block and position: absolute are great time savers, slap that on most things.
3. Ship it! Onto the next feature!
Pro-tip: Pixels totally work and you should just stick to that everywhere. The browsers and device manufacturers have kindly taken the necessary steps to make it Just Work no matter what the medium.
In case you think I'm being sarcastic, only half. Nobody cares about your beautifully cascading, resolution independent em's and semantically beautifully structure. The whole thing will be run through an uglifier anyway and probably you should just have used JS for your runtime generated layout anyway if you have any kind of dynamic behavior.

Load more comments