visit
CSS is fine. It’s just really hard, so I compile to it.
—My name is Jordan and I write a lot of JavaScript and CSS. I’m really, really good at those two things. If CSS were an olympic event I’d easily qualify but probably wouldn’t get a medal. But I don’t need a medal, because I have a trophy with a computer on it.
Come to my house and tell me I’m bad at CSS I’ve been drawing rectangles on computer and telephone screens for a long, long time. I’ve written lots of bad CSS, many thousands of lines of poor Less code, and megabytes of terrible Sass. It’s in my blood. But I’ve also written lots of good CSS! I’ve made triangles with borders, bezier curves with CSS transforms, 60fps scrolling animations, and tooltips that would knock your socks off. It’s a great technology. Give me 30 seconds I can write some plain HTML and get some fancy Times New Roman text and hyperlinks with the worst shade of blue you’ve ever seen. Give me another 30 seconds and I’ll make that shade of blue a little nicer, and I’ll use a pretty font.
It’s intuitive! If I want all my links to look the same, I can do that! Images with pretty borders and margins? No problem. That’s what this shit was made for.
It’s performant! Many person-centuries have gone into making CSS fast, debuggable, and all-around pleasant to look at. CSS is here to stay, and it’s a wonderful thing that we’re able to use such sophisticated tooling for free. Not to mention the countless blog posts and cool demos we have access to with a quick Google search. —When I was younger, I realized that I wanted my borders and link text to be the same color — and changing it in two or three different places every time was super awful. Then I discovered Less. Now I could make a @wonderfulBlue
and use it everywhere. Well actually Jordan CSS has variables now…
Then I started second-guessing all the long comments I left for why#left-section
was exactly 546px wide. (250 * 2 + 23 * 2 duh). Then I started writing my math in Less: 2 * @sectionWidth + 2 * @sectionPadding
. I guess you’re unfamiliar with calc(), Jordan, because that has phenomenal browser support…
Back when border-radius
had to be polyfilled, I started including all the prefixes everywhere, then moved things over to a border-radius()
mixin that I could just drop-in when I needed it. Well if you had only used component clas — Dude can you stop? Let me finish my article here. Sorr — It’s fine don’t worry about it, just hold on.
Sometimes, we’d remove too much code, and things wouldn’t look right. Because the homepage menu would expect .left-arrow
to be around, but now the styles for that class were in exercise.css
. Sometimes we wouldn’t notice because that .left-arrow
would be neatly tucked away behind a couple mouse clicks in a nav bar. Well you should have had screenshot testing or a stricter QA proce — What did I just say?
Anyway imagine a world where my grandmother did write machine code by hand onto punch cards. Again, riddled with human error! Got a bug? Punch ’em all again. Dropped the cards on the floor? Pick ’em all up and re-sort them, or just start over. Weird right? Couldn’t we make robots do this for us?
So that’s exactly what my theoretical grandmother did, she built a machine to punch the cards for her. Okay, she didn’t, but someone else did! And we got cool stuff like assembly code, and FORTRAN, and C. Each step of the way folks took to their equivalent twitter dot com and chastised this new technology. Just use punch cards! Just use FORTRAN! Just use C — okay I guess people still do this one.
— Which leads me to the point of this article. CSS is fine, it’s fast, and it’s been fine tuned for over 20 years now for all sorts of applications.But I really don’t like writing it. A lot of people don’t, so we develop these cool patterns to write it in. I don’t like writing in those patterns either, I have better stuff to do. And JavaScript is cool. Actually JavaScript has even more prob — *ahem*. .
Turning this:
See? Still CSS. Clean CSS. Perfect CSS. To-the-book CSS. But I didn’t write it. The robots did. The unused stuff is gone, and I can render <Example>
anywhere and know what it will look like.