Ask HN: Is it just me, or is CSS too damn hard?
499 pointsI'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 commentsYou can also extend selectors and at-rules in ways that allow you to define new, custom features, supported by JavaScript, and utilized from valid CSS stylesheets.
Given all this power and flexibility, you can go a long way toward turning CSS into the "styling language of your dreams". When you're extending CSS you also get to pick all the naming you work with as well.
Rather than trying to replace CSS, or abstract CSS away, it turns out the friendliest solution is to start with valid CSS and continue building on top it from there.
Check this out for more information about how to extend valid CSS with JavaScript: https://github.com/tomhodgins/caffeinated-style-sheets
HTML and CSS for that matter are very easy to start off. After a while, many begin to believe they are done; when actually, they are just starting off. It is one of those whom many would choose to ignore or use other tools to just “get it done”. A good designer, who can code, can do magic if s/he can go deep into HTML and CSS.
For instance, when developing interface designs for a complex or a big enough system, I advise my team to think of each and every block as something that is liquid enough to be thrown inside a container of varying possibilities. Test with few default container sizes but leave enough room that this can be just thrown in anywhere and will adapt to that containing block. This has become easier in React and other frameworks that encourage design thinking in modular blocks of designs.
Pre-processors, post-processors do help but one needs to be clear of the underlying philosophies and methodologies of CSS to appreciate these helper tools. Mastering these tool can then help work faster, smarter.
CSS is learned through practice, knowing the quarks and being able to make it work for 80%+ of the use cases. Break-up into smaller chunks of simpler blocks, have a styleguide-ish setup for yourself (if you don’t have one for your team), use development tools as guard rails. Finally, have a good post development workflow to get the final juice — task automation that removes un-used CSS, et al.
Imagine being able to get a column’s background color to extend equally all the way down the page in a 3-Column Faux Layout in 2003 (sometime around 2002-2004). ;-)
I think that in that sense CSS still irks me a bit, I still do a lot of things that just feeeel like a hack, but from what I search and google around it seems like that's the only way to do it? but I also think it's kinda fun, I like reading the MDN web docs from time to time and they do seem to explain things very thoroughly, I've had a lot of moments where things started to click after reading it.
I'd just want to point out this is completely unrelated: the best people I know when it comes to designing interfaces (both UI and UX) don't know much CSS. That's very much a creative field.
I can do CSS without many problems (nothing too fancy but slicing any interface or basic flexbox grids for layout and such). CSS isn't complex, just very foreign. Understanding the "rules" (cascading, priority) isn't hard, but knowing how to use it (how to target the element you want, what css to use to get the positioning/styling you actually want) takes a lot of practice. Though when it comes to creating a beautiful page I'm of no use.
All comments shown.
Couldn't load more comments. Check your connection and try again.