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
saagarjha#
I've written a small but non-trivial amount of CSS for my website recently, and my general perspective has been that CSS has quite a few non-obvious corner cases (margin collapsing, the exact semantics of how things will wrap or overflow) and I really haven't quite understood why certain solutions work and when some don't (when they seem to do the same thing?), and I'm not sure if it's because the model is just too complex or these are idioms that I should memorize.
fsloth#
CSS is not an art thing. It's just a configuration language with a accidental hierarchical features attached. CSS has as much to do with design as a tube of paint has with painting.

As a technology, like all things related to how browsers work really, CSS is not really a well designed part of a wholesome and complete architecture, but an accidental feature on top of a pile of an accidental agglomeration of features.
CSS is not art. It's just accidental complexity. It's totally understandable to me if it seems weird.
But if you need to learn it - maybe train yourself by small examples? Maybe you are trying to understand the layout of a complete and complex page? What if you implemented simple HTML pages by hand of increasing complexity and figure how CSS affects those? People are different learners but this sort of thing helps me along often.
And the font thing - typography has a long history. Since the chances are fairly good that your designer counterparts are font afficionados it never hurts politically to familiarize oneself at least with the history of the craft and to identify serif fonts from sans serif ones.
https://en.m.wikipedia.org/wiki/Serif
https://en.m.wikipedia.org/wiki/Sans-serif
https://en.m.wikipedia.org/wiki/Typography

ddebernardy3 replies#
FWIW my father struggled with CSS for countless years before retiring. The reasons were he never got his head around the DOM or the CSS box model and the fact that it all assumed you were using CSS to style a document (or more specifically, a DOM tree). He would instead want to place this/that here/there, oblivious to the fact that he was building a web page that scrolls, rather than a more familiar VB app screen that does not.

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.

onion2k#
The reasons were he never got his head around the DOM or the CSS box model and the fact that it all assumed you were using CSS to style a document (or more specifically, a DOM tree).

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.

baroffoos#
>He would instead want to place this/that here/there, and never really got his head around the notion that he was building a web page that scrolls,

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.

shmooth#
holy shit i'm old.

Load more comments