As JavaScript developers, the sheer amount of stuff we're expected to know is enormous, and it grows bigger every day.
With so many different languages, tools, and technologies competing for our time and attention, it can be tough to figure out what to prioritize. Should we get better at TypeScript? Maybe pick up Svelte? Will we even be writing JS in the future, or is this “WebAssembly” thing for real?
In my opinion, if we really want to maximize the return on our investment, one of the best things we can focus on is CSS.
This may seem like an odd choice, but honestly, getting better at CSS has had an enormous impact on my life and career as a developer. In this article, I'll share some of the reasons that I think it's such a good idea.
Link to this headingIt improves your quality of life
I've spoken to so many developers over the past few months who just find CSS miserable. I have a hypothesis about this.
CSS is a very implicit language; it relies heavily on mechanisms buried deep in the CSS specification. When those mechanisms work in ways we don't expect, we're left in the dark, not sure what the heck is going on. We don't know what we don't know.
Compare that to a language like TypeScript: when we make a mistake, a helpful tooltip pops up to let us know what we did wrong. Even in loosey-goosey JavaScript, exceptions point us in the right direction (and plus we have linting, breakpoints, logs…).
When we write code—in any language—we rely on our mental model of how that language works. If our mental model is incomplete or incorrect, there's a good chance that we won't get the result we were expecting. In CSS, those misalignments are super common, because of how implicit CSS is.
Let's look at a quick example.
In CSS, the z-index property can be used to move an element above or below another element. In this snippet, the pink box sits in front of the gray one because its z-index value is bigger:
Code Playground
Result