Ask HN: Is it just me, or is CSS too damn hard?

499 points by napsterbr ↗ HN
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?

357 comments

[ 5.3 ms ] story [ 224 ms ] thread
Everything takes practice. Everything takes practice.
It's not just you. I'd recommend using a CSS framework. Have you checked out Bootstrap [0]? I was very much the same way (focused on backend). CSS is just a means to an end for me, in that I just wanted something that doesn't look like total garbage, so I used Bootstrap for the frontend bits. Allows you to quickly get up and running using the examples without learning too much CSS [1]. Just find something that looks like what you want and then copy/paste. Much much easier.

They have a pretty nice grid system that allows you all types of formatting options (desktop/mobile). All types of text formatting options too. Honestly, I think you're way better off learning something like Bootstrap unless you want to do this professionally.

[0] https://getbootstrap.com/

[1] https://getbootstrap.com/docs/4.2/examples/

EDIT: downvotes? Why not mention why you don't like bootstrap and share with the larger thread? At least, then it is useful to everyone else.

There are some use cases for Bootstrap for sure, but I feel you need grasp the basics of CSS first. It is like using jQuery for everything instead learn proper Javascript.
Until you get to the point where you are reinventing jQuery vs just using it. The same thing can happen with CSS, you are formatting all this stuff, getting a layout, spending tons of time fixing layout issues in CSS, etc. Where your time might be better spent just using Bootstrap and working on your app vs CSS.
Don't use bootstrap for anything beyond personal project prototypes. It ends up being a complete nightmare for maintenance. Coupling of DOM with presentation and state is the number one thing we should be avoiding in modern JS apps.
Interesting, I'll have to read about that. This has totally not been my experience.
It works great... for a while. Then you end up wanting to tweak something here and there, start adding classes to things, and you realize you want to do something that requires changes to the DOM within a component and you're screwed. Or you ignore the fact that the right way would be modifying the DOM, use some hacky CSS to kludge it, and you start getting browser inconsistencies. Either way you end up stuck with 100k of dependencies to style a popover and a dropdown that could have just been defined in a design system from the get-go and done with minimal CSS in a React/Vue type architecture scoped to the individual component.
Ah, that does make sense. Thanks for adding the examples -- I can totally see this happening. Guess I just haven't been bitten by that yet. Although, I do remember running some mass regex through the codebase to update class names when bootstrap changes something. Or, changing templates to use some new formatting. This can be nerve wracking.
My frustrations w/ CSS stemmed from not having respect for the complexity of the problem that CSS solved. I went into it w/ the same attitude of "hey, just center this thing", and didn't really get anywhere. These days I have accepted that CSS is a tool for pros, which I am not.
> hey, just center this thing

Step 1: On your container div...

display:flex; justify-content:center; align-items:center;

Step 2: There is no step 2.

this won't work on bootstrap elements
Are you using the bootstrap’s utility classes?

.d-flex.align-items-center etc

Another reason to avoid bootstrap if possible. I wouldn't touch that thing with a 10 foot div.

Each to their own, but it's better to make your own templates, unless your primary role is something other than frontend dev and you want the equivalent of store-bought pasta sauce instead of making your own pasta sauce.

Yeah, with flexbox we can finally do the layouts we could do with tables since 1996, and it's only a little harder.
With display:table from CSS 2 you could do the layouts you could do with HTML tables. Flexbox solves a different problem - for example you can't have rows and column in a flex. There is some overlap in functionality, but generally flex is more convenient to use.
It clicked a bit more for me understanding the box model better. More recently flexbox makes things a lot more clear/easier and handles a lot of those problems by default. I have no idea how design works, that seems a bit more art.

EDIT resources

I personally love https://cvan.io/flexboxin5/ for testing and https://flexboxfroggy.com/ for learning flexbox

>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.

Yeah, you're not a designer.

Note I'm not insulting you. :)

CSS is very much like magazine or print layout IMO. If you're not used to that, it won't gel well. If you think of layout from a design perspective and _not_ a programming perspective, it's really not that bad. The warts more come down to differing implementations across browsers, which has become far less of an issue in recent years.

I expect you'll get a very different response from the crowd here, though, so consider it my two cents. I've done much backend work (like yourself) but started in frontend, so I feel adept enough to work with CSS well when I need to. shrug

Can I be really predictable and give a "very different response"? Worked in magazines for years, still do a lot of print cartography, and I find CSS a completely different mindset to Illustrator or InDesign or Quark or whatever.

It just feels like a weird outlier to me - not freeform enough to fulfil the "design" role, not programmatic enough to fulfil the "developer" role.

Same for me. As someone who's done a lot of layouts in InDesign, it seems to me that CSS is only starting to offer decent tools to reproduce that mental model (e.g. CSS grid). But somehow doing incredibly basic things such as positioning or aligning elements can still take inordinate amounts of time.
Yeah, I hear this a bunch, and I can see why it'd feel that way. My standard response is that HTML/CSS simply didn't advance enough for a period of n years to make it easier, so it (for awhile) was arguably stuck in the late 90s/early-mid 2000s for layout concepts. The other response to you noted it's gotten easier lately too.
Yes, this. So much this.
I too worked in catalog design / printing. I had a lot of catalogs from many manufacturers (some 5 to 10 years old). This was how I learned UX design, I benchmarked design decisions made by other companies. Since I knew how those companies operated, this gave me insights on what good/bad designs are.

Designing a catalog is similar to designing a SaaS tool.

Designing a magazine is similar to designing a marketing website.

Working with AdobeIndesign taught me the following things, that translated into web development:

(1) Importance of style guides (things like BEM, SMACSS, etc): If you don't lay these out upfront, your catalog becomes incredibly inconsistent and hard to manage (too many components everywhere).

(2) How to organize your SCSS files - it's actually almost the same way you do it in Adobe Indesign. There's a `base` folder for global layout styling (fonts), `components` folder for things like buttons, tables, etc.

(3) How to layout a webpage. In Indesign, you start with the header/footer usually in your masterpage layout. Then you design each page from top to bottom generally (for a catalog at least). The viewport is more or less the size of a single page. You can only fit so much content there.

(4) Font-types - Open indesign, dig through all 100+ font types and see what the differences are. Some can handle fractional fonts, others have support for narrow styling (Arial).

(5) Design combinations - Take a look at a Grainger or McMastercarr catalog. There's many tricks for cramming a lot of information on one page. Minimal font sizes, horizontal lines in tables, use of white-space eye relief, consistent styling, etc.

(6) Constraints - If you saddle-stitch or 3 punch bind your catalog, your margins differ. If you make brochures, it's like designing for mobile devices

(7) UX Interaction - There's many ways of looking at a page, and where you want to draw a user's attention first.

UX tools are still playing catchup to what Indesign has offered for years.

I would say CSS is different mindset in that there are more rules. And you have to usually handcode it yourself. It's "design" in the sense of knowing what colors to use, size of content, etc. "Development" in the sense of knowing how to use master-page layouts / component designs upfront.

It sounds like you just haven't put in the effort/time. I very much doubt that CSS is "too hard" for you.

I've had similar experiences with regex, shell, & vim. If you're not doing it all the time, it's easy to just brush it off to the side or google whatever you need to do.

No reason to be an expert in something you're only going to use once in a while.

I would put regex shell and vim all in the same bucket as being esoteric and hard to learn since they don’t replicate any of the normal syntax and patterns you are used to. Actually, they are arguably even weirder than CSS.
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.

I hate css, but one of my colleague (who's really good at it) told me once that people have problems with css because they don't study and take it seriously. I.e. I spend so much time reading on new languages and design architectures, but besides some articles here and there I don't study css or take it seriously at all. So yeah, there you have it.

I also think it's getting better. One major problem with css was getting it to work across all browsers, but now if you're lucky enough to only have to support modern versions it's so much easier than it used to be!

The thing with CSS is it's not a programming language. Progamming skills and CSS skills are almost completely orthogonal. It is simply a domain of practical knowledge that takes years and years of dealing with all the idiosyncracies, cross browser issues, and silly warts of historical legacy that come with it to master. That being said, it is without a doubt the most powerful and simplest layout tool in existence. Things like QT can come close, but really nothing else is as as simple and easy to use while still being extremely performant and highly customizable. There's very very good reasons why practically all software nowadays has gone to HTML/CSS based UIs.
> There's very very good reasons why practically all software nowadays has gone to HTML/CSS based UIs.

One being that practically all software nowadays are webapps and there's no choice. For those that aren't webapps and whose GUI toolkit use CSS or something like CSS, it's probably to try to pull people that already have experience with webapps.

> and there's no choice

And this is the thing that many web developers miss. As they've begun to creep into the mobile and desktop space, intent on replacing native experiences with a continual barrage of non-native, bespoke apps, each with their own design, they've mistaken widespread availability with quality and utility — that HTML/CSS UIs are widely available is all to do with ubiquity and lessening an otherwise not-at-all steep learning curve, not technical merit.

Give me springs and struts, Autolayout, or PowerApp's style declarative positioning any day.

>Give me springs and struts, Autolayout, or PowerApp's style declarative positioning any day.

Positioning is one thing, but CSS really shines in it's graphical abilities. Autolayout is fantastic, but have you tried writing the custom CoreGraphics code that is required to do anything outside of standard UIKit visuals? Not fun [0]. Being able to just type `background: linear-gradient(orange, green)` is a godsend compared to that stuff.

[0] https://github.com/amraboelela/myos.examples/blob/master/Cor...

Then I guess my dream system marries the two concepts, somehow. I don't think we should accept CSS just because it's what we have; far too many people find it confusing and dislikable.

At this point, I'm starting to look into things that "transpile" to CSS.

IMHO I think that one of the main problems with CSS is that it doesn't have an explicit model of text. If you have that, then a constraint-based designer can take you through wizards to ask to to consider eg. When there's more text than space. Springs, struts etc. Can take care of layout. Controversially I think we should replace/remove div tags as they don't make all their behavior explicit vs flexbox/ cssgrid etc. Every object should have explicit layout behaviors defined. Then you can compose them or create new objects for undefined cases.
I actually prefer coding CSS from scratch. Color schemes and making things look nice IS hard, for my previous and current projects I had to get feedback from friends, family, end users, graphic designers, etc. UX is hard, it's a different field than programming, but there is a method, research, and science behind it.

Here's a good resource for UX: https://goodui.org

And here is one for color theory: https://uxplanet.org/color-theory-brief-guide-for-designers-...

I also really enjoy building CSS UIs from scratch, but editing existing stylesheets is a pain point. Band-aid after band-aid.

I think keeping UI components tiny and coupling the stylesheets with the component is the best way I've seen (not necessarily styled components, just styles in the same folder as the component.)

As the component is removed, its easy to nuke the stylesheet with surgically removing related styles and not breaking something else.

Why not styled components? It’s what immediately jumped to my mind while reading your comment, until you said otherwise :)
Styled components, CSS-in-JS and CSS modules largely solve the same problem. I think it's just a matter of preference.
>I also really enjoy building CSS UIs from scratch, but editing existing stylesheets is a pain point. Band-aid after band-aid.

I feel the same. I fiddled with css on personal projects just fine, but in my job, diving into years of accumulated, imbricated classes is a nightmare and even though I try, 80% of the time I end up passing the problem to the design team.

Same here. I recommend to avoid bloated kitchen sink frameworks like Bootstrap and Foundation unless you don't plan to do any customizations at all and only include the parts you actually use. Otherwise you'll realize that you're actually fighting the framework by trying to override it.
(comment deleted)
it's you. CSS is basically the most simple thing about Front-End dev.
I work as a frontend architect and UX lead (yes, it's tiring), and you're encountering a common problem.

Javascript is logical (sort of...), and a lot like learning math. It's fairly easy to validate your output. It works well with the logical side of your brain.

Learning CSS is a lot like learning English. There's the basic grammar, but also tons of edge cases, dialects, and straight up absurd rules (Buffalo buffalo..). It's a language primarily improved through experience and memory.

CSS has undergone LOT of development last few years, so things like div centering can now be solving by margin (oldest), flex (newer), and grid (newest), but only in certain browser. It's a language you must constantly keep up with.

Design is just colors and fonts right? (At least, that's what my CEO says). It's important to realize that good design is as hard as good code, and you really benefit from a similar education. That being said, cheat by using a color wheel or Coolors.co

Fonts all look the same until you learn how to look at them. Wine all tasted the same to me until someone taught me what to look for. Without knowledge about why fonts are a certain way you'll never be able to pick one, but it's totally possible to pick that knowledge up. Find a beginner book on fonts and you'll be on your way in no time.

A layout engine and design are two entirely different concepts.

CSS has nothing to do with design. It is the tool used to implement the design and there are loads of other layout tools out there that don't have CSS's infuriating quirks. On the flip side, they usually have steep learning curves because they are strict.

For a long time, until less than a decade ago, designers knew nothing about CSS. They'd do a design in pictures and their design would be implemented by a programmer.

Some (unlucky) programmers entire job was turning PSDs into HTML and CSS.

> Some (unlucky) programmers entire job was turning PSDs into HTML and CSS.

That was my entry into programming many years ago. But I wouldn't call it unlucky - early web devs like me (we didn't really call ourselves programmers back then) had front-row seats at the beginning of a revolution, and it certainly was entertaining to watch and be part of.

> CSS has nothing to do with design

CSS works the way it does because it was created to make the kind of designs that designers wanted possible. It has everything to do with graphic design. All the web designers I knew back in the early days knew some HTML and CSS and we'd often discuss possibilities and limitations of browsers and standards, and how to work around issues. They didn't just lob PSDs over the partition to the devs - there was an active dialogue and they knew their stuff.

> CSS works the way it does because it was created to make the kind of designs that designers wanted possible

Well, not originally. Later that became a thing, yes - but all the design that was already there at that point (circa CSS 2) remained, as did the overall approach with cascading styles.

A styling language designed for HTML5 today from scratch, accommodating modern use cases, would likely look a lot different.

It would probably be written in JS, maybe something like JSSS [1]. I remember playing with it when it came out and thinking it was very cool. Pity it never went anywhere.

If we were going to start from scratch though, we wouldn't do HTML5, we'd use some other format. JSON maybe?

1. https://en.wikipedia.org/wiki/JavaScript_Style_Sheets

Display PostScript? Only kidding, maybe.
Extremely doubtful, given that many of the modern ones have been written in XML (e.g. xaml, android) and iOS went old skool with a drag/drop GUI.

No-one went pure code (because it's a massive PITA).

^this

I think the best illustration of this "fight" between CSS as a tool for styling "traditional" hypertekst documents, vs CSS as a tool for styling "web pages" is the fate of Adobe's CSS regions proposal - and Håkon Lie's opinion piece arguing against it:

https://alistapart.com/blog/post/css-regions-considered-harm...

That was when "design" lost. But now with grid and transitions, there's a "new" CSS - one that is oriented around UX for "web apps". But apps evolved from documents, mind - not from windowing toolkits like smalltalk morphs or Java swing etc.

Fwiw I really liked the idea of regions for laying out rich documents - like what you might want for epub.

I must admit I'm not that concerned about "web apps" - everyone seems to end up doing their o we n abstraction anyway, and the CSS that "falls out" isn't really sane anyway.

I just wish we decoupled apps and sites, instead of forcing it all together in a large and incoherent design. This is especially painful now that it's spilling over into the desktop world because of all the Electron apps.
>They didn't just lob PSDs over the partition to the devs

You were one of the lucky ones. I worked with designers who would've done fine designing a printed flyer, but couldn't comprehend the idea of a scrolling website with dynamically-populated content (of varying lengths) being viewed at different sizes on different devices/browsers.

Their solutions were along the line of "Force the browser to be XxY resolution and limit the number of words that can be entered in this area."

> All the web designers I knew back in the early days knew some HTML and CSS and we'd often discuss possibilities and limitations of browsers and standards, and how to work around issues. They didn't just lob PSDs over the partition to the devs - there was an active dialogue and they knew their stuff.

I find this false. PSD-to-code was very common back then. There even still some designers today that only work via images/PSD.

Not disputing the 'PSD-to-code'. Did it myself many, many times. I was disputing the idea that designers knew nothing about CSS. The good ones did.
I remember slicing designs in Photoshop into sections, to be dropped into pages...gross.
> CSS has nothing to do with design.

What a bizarre statement. That's like saying words have nothing to do with stories, or paint has nothing to do with art.

I think there's edge cases, dialects, and straight-up absurd rules in JS too.

I don't think CSS is any less logical... but some might not be use to _declarative_ languages like CSS is?

The difference is that with JavaScript, you can install a linter and happily restrict yourself to the sane subset of the language. It's very realistic to never have to deal with any of the uglier parts of JS, even as a full-time front-end developer.

With CSS, you can't avoid hacks. If you try to design anything non-trivial, you will have to employ tricky non-semantic tricks, run into edge cases, and have to settle on ugly, non-optimal solutions.

I don't think it's a declarative vs imperative thing. It's more that CSS was designed to be easy to use and relatively terse for a specific, outdated use case (20+ years ago when a website page was thought as a 1 dimensional flow of text and pictures).

Nowadays our requirements encompass pretty much the full spectrum of 2D space design, yet we still use a language that builds on high level primitives designed for a narrow usecase.

New features like Flexbox and CSS Grid help with the layout part, but it's not enough.

> 20+ years ago when a website page was thought as a 1 dimensional flow of text and pictures

Here's the thing though — most websites are still just a '1 dimensional flow of text and pictures'. They try to disguise it with multiple columns of guff, but it's still just text and images. Sometimes a video.

Sure there are web 'apps' now too, but most websites are not apps (thankfully).

>Sure there are web 'apps' now too, but most websites are not apps (thankfully).

The thing is, web apps are also just a more complex version of the same '1 dimensional flow of text and pictures,' just maybe with Canvas and a lot of javascript. There's no real difference between a web app and a document, as far as HTML/JS/CSS is concerned. The dirty secret of the whole "the web used to be documents but now it's applications" meme is that the applications are still documents.

What does installing a linter have to do with using a subset of a language?

Just... use the constructs you're familiar with? It's not like you can "accidentally" use an ES6 class or something.

You can accidentally use == instead of ===, or even accidentally use the assignment operator instead of one of the comparison operators.

You can know about for..in without knowing about hasOwnProp.

You can forget to enable strict mode.

The list goes on. Static analysis is universally a good thing.

(comment deleted)
installing a linter and limiting yourself to a subset of the language has to do with the fact that most development is done in teams, so when you limit yourself you limit the team to an agreed upon good subset of the language and nobody screws you over because they think the with statement needs a workout.
I experience the same than the author. But I have absolutely not the same problem with a declarative language such as QML, Cascade, Android xml, Jboss rules engines, etc...

I don't think it is caused by this aspect of CSS.

The problem could come from the fact that it mixes 2 purposes: style AND layout to apply it globally with rules that get harder to understand the bigger the project.

(comment deleted)
>tons of edge cases, dialects, and straight up absurd rules (Buffalo buffalo..). It's a language primarily improved through experience and memory.

Yeah, I'd sum it up by saying CSS makes hard things barely possible and simple things hard.

The example OP gave of centering divs illustrates this point, and there are unnecessary weaknesses in laying out a page when, for example, sizes aren't known in advance. Overall, there's a divide between intuitive expression and output, wherein the browser ends up saying things like, "I won't do this (e.g. center) unless you also do that (e.g. tell me how big it is)." Really? Why?

In all, it's never been an efficient solution to the problem it seeks to solve. When the Great War on Table-based Layouts broke out, it was even less suitable, which made it even more painful that you were persona non grata for resisting. So, rather than demand a better standard and uniform browser support, we just hacked and kludged and shimmed around it. So, the need to support the legacy has made it even more impractical to fix, hence the attempted do-over with flexbox.

CSS has been the bane of front-end development for many a dev. Amazing that we largely just suffer through it, and its tyranny has reigned for so long.

If anyone doesn’t get the “Buffalo buffalo...” reference here’s the Wikipedia about that bizarre English sentence [1].

[1]: https://en.m.wikipedia.org/wiki/Buffalo_buffalo_Buffalo_buff...

Oh wow. I'd always just assumed it was a US idiom along the lines of yada yada or something. Buffalo buffalo... doesn't work in British English as it is only a noun.

Nearest English silliness I can remember hearing is: police police police police.

Don't tell me you can't verb a noun in English English? "police police police police" - please...
Of course nouns have been made verbs in English. You'll find no British English dictionary listing where buffalo is, unless noting US usage, where it is both.

Police police police police is grammatically correct, but of little meaning : (the) police police(v) police (of) police (ie overseers of the police).

I read it as: police police (Internal Affairs) police(v) police.
FWIW I'm an ESL speaker from a non-English speaking country and despite having had endless exposure to (mostly American and British) English since a young age, I've never encountered the verb form of "buffalo" outside that one sentence. It's an informal North American idiom and by international standards apparently a fairly obscure one.

Policing OTOH seems to be a fairly widespread verb form with a clearly understood meaning (i.e. what the police conceptually is supposed to be doing). Unless you have close experience with buffalo, you probably can't infer buffaloing means "intimidating".

EDIT: Also as mentioned elsewhere, not everyone outside the US knows there are places actually called Buffalo or makes that leap when hearing the word "buffalo". So "Buffalo buffalo" is more likely to be read as "buffalo(n) buffalo(v)" (which already sounds weird if you don't already know what "to buffalo sb" means) which breaks down as soon as you add more buffalo to the sentence.

It’s extremely obscure as a verb in North America too, fwiw.

Buffalo the city was probably better known 150 years ago, when it was an economic powerhouse as one of the end points of what’s still the second most famous canal in the Western Hemisphere. Afterward it continued to be a significant industrial center until the decline of manufacturing turned the Great Lakes region into part of the “Rust Belt” in the past 50 years. Most Americans probably know of it these days because it still hosts an American football team.

Anyway, the point isn’t that that’s a common sentence. It’s that it’s a grammatical one.

Everything you say rings true ca 2000 to 2012. Today, CSS and the rendering engines have both improved and converged to such a degree, I’m not sure it’s fair to still criticize them quite so harshly.

Of course the cutting edge will temporarily see one rendering engine a few months behind another. But that’s unavoidable unless you prefer a monoculture, which is liable to move slower than slowest of today’s major rendering engines.

It’s perfectly normal today to create CSS (and JS) in one browser and find it working flawlessly in another. 10 years ago, you would have called everyone over to your screen to have them witness this miracle.

> Javascript is logical (sort of...), and a lot like learning math. It's fairly easy to validate your output. It works well with the logical side of your brain.

No, it really isn't.

Some languages are, JS definitely isn't. It's mostly illogical / broken / mental.

That isn't an argument, you're just expressing your disagreement.

Even if it were an argument I'm not even sure it would be an argument worth having because it's likely entirely orthogonal given the context of the original statement (i.e. contrasting JS with CSS and HTML -- where whatever esoteric programming language you're thinking of is not an option to begin with).

if you avoid the absurd parts, JS is perfectly acceptable. The standard ways people write modern ES6+ CSS is fine.
I’m in the same exact role, leading both UX and FE engs. It’s exhausting.
I think there is a spectrum Of skills with programming at one extreme and visual design at the other. Even within “front end” you tend to have JS experts and CSS/design/UX experts. Some people can do both.

When you consider UX, accessibility, progressive enhancement, cross browser and cross device support - there’s plenty to know. And unlike programming, it doesn’t all flow logically. Some stuff is subjective, other stuff requires specific knowledge of browser quirks etc.

The only site that helped me gain some _understanding_ of CSS (as opposed to knowledge, tricks and hacks) was this one http://learnlayout.com

It’s a bit dated now - Flexbox is mentioned at the end and CSS Grid is entirely absent - but still important if you’re supporting older browsers.

But CSS has never “clicked” for me. For a start the whole idea of cascade is based on inheritance and I generally prefer composition. I like designing UIs and it’s quite a satisfying challenge to match a wireframe to the pixel. But overall, I’d rather be writing application code.

If users could just read JSON everything would be a lot easier...

I don't see get why anyone thinks that CSS skills and design/UX skills somehow go together. It seems to me that the skills needed to write CSS have more in common with those needed for programming than for UI design.
It might be a visual/spatial disconnect because you mention you cannot intuit color contrast or distinguish fonts or failed at how design works. CSS then would have no meaning to you. Imagine asking a deaf person to describe music in notes. If it has no true meaning to you, it is nearly impossible to grasp. If this is the case, I would rely on a UI toolkit that has theme support so you can easily change between them and not care about these types of things.
> I can't center my divs properly.

This is actually pretty simple, once you understand how "block" elements work. Block elements will always try to fill up the "available width" i.e., they stretch side ways. The sum of margin + its width must match the total width.

Inline elements will fill up its parent block like text.

So, a simple example - suppose you set a div's width to 100px, and margin to auto, then you will a 100px wide box centered.

I see people get confused when they try to have a block that has an unspecified width and hope CSS just figures out.

> This is actually pretty simple, once you understand how "block" elements work.

I disagree -- in this and every case where someone has told me that something is simple once you understand the fundamentals. Understanding how a tool works is completely different from understanding how to use it to accomplish a particular goal. One's a deconstructive process, and the other is a constructive process.

CSS is crazy.

To keep my sanity, I try to avoid touching it as much as I can (I use Semantic-UI which gets me most elements with little effort), and when I have to, I try to stick to the more recent, reasonable parts. Flexbox for example is understandable and predictable.

(comment deleted)
I remember when I first told my colleagues that I followed every single CSS course on Lynda, they laughed. They thought why would you spend all this time on a non programming language?

No one takes CSS seriously. For most, CSS comes as an after thought. Build every part of the application then suddenly "Oh Right! CSS!" Slap bootstrap or other popular framework then don't think about it.

Yes, CSS is not a programming language like others but it is just as complex. It requires studying, practice and long exposure to become versed in it.

Note: you can google your way into using a couple jquery functions, but you can't become a competent JavaScript developer like that. The same goes for CSS.

> Build every part of the application then suddenly "Oh Right! CSS!" Slap bootstrap or other popular framework then don't think about it.

It depends on the problem your trying to solve, if you just want something that looks decent (because you're a programmer and you don't notice things like colors, alignment and spacing) then something like bootstrap is a good go-to.

I still think learning CSS properly is worth it, using bootstrap without knowing CSS is like using an ORM without knowing SQL, but less dangerous.

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.
CSS isn’t bad after writing it a lot and googling the same tricks to do what typically works. My best advice is to stick to some framework for most UI (material or bootstrap) with using custom css seldom. Colors are definitely an art form and matter a lot.
CSS doesn't seem to be experiencing the same revival or energy that JS is still experiencing.
I'd disagree. There is a lot of new stuff to CSS making our lives HUGELY easier.

Classic example is CSS grids that is only recently starting to become ubiquitous in commonly used browsers, and the new units of measurement that go along with it like 'fr'. CSs does not feel stagnant to me, but is evolving I think... Perhaps not at the breakneck speed that JS libraries are, but then the core of ECMAScript is not going as fast as JS libraries either.

Experience. Reading what features there are and trying them out.

CSS can be fun. Its easy to learn but hard to master.

Be careful; if people recognize you know anything more than basic CSS, you’ll become the CSS helpdesk

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...