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
pmarreck1 reply#
CSS is declarative. Code is procedural/imperative.
dragonwriter#
Except logic, (pure) functional, and some other kinds of code, which is declarative.
andrewmcwatters#
As far as small projects go, it's useful to take what you've learned from larger projects like Bootstrap, and use a subset of that knowledge.

For virtually everything else in production, you should be using themed Bootstrap or CSS framework x, y, or z that fits to your corporate identity. Usually so you can have a front-end engineer make decisions about symbols and have those changes flow out to the rest of your webpages and web apps without relying much on engineering to hand tune everything all over again. This is sort of ideal CSS usage, though it's probably debatable by folks here.
CSS is development more than it is design. It just helps you accomplish design.
Maybe one of the points glanced over CSS discussions is that the traditional visual formatting model was designed for documents, and not web page and web app layouts for today's world. That's better addressed by flexbox and CSS grids. For instance, the entire concept of floats isn't for aligning things, it's for text to flow around "floated" boxes like images. Most hacks like clear fixes were designed to help utilize floats for page layout versus document composition.

jstewartmobile#
> Is CSS an "art" thing?

Certainly![0]
> Is it common for other developers to have issues with it?
Boy howdy it is! Like eight years of discussion[1] on vertically centering text in a div. It's all siegeworks-engineering[2] anyway, so no surprise that we ended up here.
I think at one point in time, poor Doug Crockford suggested actual versioning for things like javascript and CSS. The children shivered as though they had been visited by a ghost! And after brushing the chill aside, returned to our great undertaking of cramming as many different languages into a .js file as humanly possible.
[0] https://www.widewalls.ch/andy-warhol-piss-paintings/
[1] https://stackoverflow.com/questions/2939914/how-do-i-vertica...
[2] http://2ality.com/2011/03/javascript-how-it-all-began.html

droithomme1 reply#
I always end up having problems using css to do layout, like you mention that it's often a pain to center things. I prefer tables for a lot of things that I'm not "supposed" to use table for because the css methods don't work the same in various browsers, or at all in older ones.

css for markup works fine for me.
A humorous experience for me is when I look up some css concept I can't remember the details and find sites and blogs by css gurus about it, but their site is a total mess, unreadible, with for example letters as large as the screen, all readible text in a div that is off screen, etc, and turns out their blog only renders properly at all when viewed in Chrome. Seems there's lots of css experts that advocate for weird features which only work in one browser.

eyelidlessness#
I won't fault you for finding tables intuitive for layout, but please stop using the actual table elements to do it. You can use normal divs with table styling for exactly the same outcome: https://caniuse.com/#feat=css-table

Semantically it does make a difference, and can impact people using accessibility technologies.

Load more comments