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
ummonk#
I have a lot of aesthetic sense, and a strong eye for good layout and design. I still struggle every time I need to use CSS. I know enough to eventually make it do what I want with a lot of experimentation and googling, but not without a great deal of difficulty. I’ve known CSS whizzes who can make it do what they want easily, but they’re extremely rare.

I think it is just a really poorly designed framework. Other layout toolkits for native programming are typically far easier to learn and use.

TylerH#
The main things you should learn to become decent at CSS are:

- the box model
- how cascading, specificity, and inheritance work
- googling CSS problems with the site:stackoverflow.com filter
Bit tongue-in-cheek with that last one, but the rest will give you a solid understanding of why certain things work the way they do when your code doesn't look the way you expect.
> I can't do anything basic on CSS without turning for help
The thing is, if you are working with a whole website (even simple looking websites can have a lot of HTML and CSS), then there are often no "simple" problems, at least with layout, because every element can and often does affect every other element.
Sometimes you just need a good old analogy or picture to demonstrate some things: https://stackoverflow.com/questions/33132586/why-isnt-my-mar... (disclaimer - I wrote that answer). In a lot of ways, your elements and their CSS are like rocks in a river... the water/document flows around them in certain ways, which affects stuff around them or downstream. Removing one or adjusting it can change how the water/document flows, and thus can affect other rocks/elements, etc.

roryokane#
When I was struggling with CSS at my first job (2011), the thing that made it click for me was learning the significance of the `display` property and its possible values. After I learned that each `display` value causes the element to be rendered in a certain way, and that some CSS properties were only useful for certain `display` values, it became much easier to predict how the layout would look and to organize the CSS properties in my head.

For example, it cleared up a lot of questions when I learned that `display: block` elements naturally expand to the greatest width they can while matching the height of their contents.
Also, the Mac app CSSEdit (now folded into Espresso; https://espressoapp.com/) helped me learn the various CSS properties thanks to its GUI interface that listed properties by category, such as Text, Decoration, and Layout. It had icons for each possible value of each property that made it easy to remember what values each property supported. A useful feature of the app was letting me load an arbitrary web page and edit its styles with its GUI editor – I could see which properties were more often useful and how switching the between the possible values would change the look.

mch82#
I arrived at CSS and HTML from a background in print layout with Adobe PageMaker and InDesign in the 1990s. Professional layout programs like InDesign attempt to separate content from layout and styling. The first step in creating a print document is to set up a grid of empty containers. The second step is to fill those containers with placeholder text (often Loren ipsum). Step three is to develop a style sheet to style the text so that styles can be updated in one place and applied consistently throughout a document. The last step is to flow content, written as plain text in an external copy editing tool, into those containers.

Coming from that background, HTML (the document structure) and CSS (the style sheet) are relatively intuitive. I can see how they were influenced by tools like InDesign. However, browser quirks are very frustrating. I try to avoid situations where I need to deal with them, or if I do I try to find CSS written by others that guides the way.
I think it’s probably unfortunate that screen layout techniques, where screens are variable size and interactive, were so heavily influenced by print layout, where pages are of fixed size. On the other hand, maybe HTML + CSS was too influenced by Microsoft Word style desktop publishing where layout and content are in a single document and not influenced enough by InDesign style publishing were layout, content, and structure are each distinct. But relatively few people are ever exposed to professional print layout tools like InDesign.
Having recently gotten into parametric CAD and constraint based design, I’m hoping to see more of that approach make its way into both print and screen design.

Load more comments