14 ms·
The Importance of Learning CSS
- firefoxd 6y agoI learned CSS twice. The first time was like everyone else does. Google tricks here and there. How to center div, how to create columns with divs, how to do rounded corners etc. This will only get you so far. The second time around, I took a bunch of courses online, lynda, one of by designers, and bought books. Once you understand the fundamentals of CSS, you can work just fine with css2. Css3 is just an added benefit and great for animation.
- eurasiantiger 6y agoI’m in the same boat. ”Learnt CSS” in the late 90’s/early 00’s, and learnt it all over again in the 010’s. It’s true, CSS2 is all you need to build any layout. I actually prefer float grids over flexbox and CSS grid. Float grids are so simple to use in comparison, and all it requires is a list of breakpoints and two to three SCSS mixins, depending on how fancy you wanna get. But no way I’d write it without modern tooling.
- sixQuarks 6y agoAre you sure you know flexbox and grid well? I don’t see how you could prefer floats.
- petepete 6y agoGrid and flex let you do in five lines what used to take fifty. I'd never go back.
- eurasiantiger 6y agoThank you for your quadratic-or-worse layout calculations. Then people wonder why the web eats their phone battery.
- wwweston 6y agoFloats have their place. The conceptual model is simpler for some simple cases, and you can build layouts that reflow over different viewport sizes without worrying about breakpoints. Once you need equal-height boxes in your layout, though, it's time to use something else.
- eurasiantiger 6y agoThey are faster to render especially when resizing the window, and they work in the exact same mental model of layout as everything else in CSS: the box grows to fit its content. Flexbox and grid do not subscribe to this: flexbox shrinks/grows its content to fit itself. Grid is a configurable beast, something in between, and also makes it possible for grid content (not the container) to define how it itself is laid out.
- aitanabewa 6y agoI'm on my second time (: . Do you have links to the resources that you mention?
- cpmsmith 6y agoThis is only applicable if your brain is wired a certain way, but in case it is, I strongly agree with this note at the end of the article: > The CSS specifications are surprisingly user-friendly! I learned a ton reading the [Flexbox spec](https://www.w3.org/TR/css-flexbox-1/ https://www.w3.org/TR/css-flexbox-1/). The CSS specs are fairly intelligible (as specs go) and once you have enough base knowledge to get a foothold while reading them, they force you into thinking about CSS much more systematically, because that's how specs are written.
- whytaka 6y agoAs a designer that used to make pixel perfect websites turned developer, CSS lets me offload so much of what I need in building UIs and keeps my templates/JSX as close to data representation as possible. With my components having tightly scoped CSS, the only CSS I share between my components is very universal branding settings. My class names make sense and my SCSS reads like the DOM, and the only non unique dom-selector class name is the 'active' state. I loathe having to deal with so much layout building classes in my dom, having to swap them for responsive layouts, etc. My css determines layouts. My html presents data. It keeps my javascript very focused on function.
- runawaybottle 6y agoGood point. People that suck at css usually stick a class on everything and the templates become a mish mash of data, styles, and elements whose semantics are determined by some arbitrary class name. I love me a nice tight jsx template with maybe one or two classes sprinkled at the top level containers.
- eurasiantiger 6y agoCSS-in-JS is the biggest, stupidest mistake on the web, ever. Do not use it. Componentize using BEM classes and SCSS and your designers will love you.
- Animats 6y ago"(Learning CSS) improves your quality of life" If you have to create web pages by hand, it probably does. If you have to read CSS created by others, no. Unfortunately, when CSS was created, constraint solvers were rare and object inheritance was too popular.
- smoldesu 6y agoGod that is an annoying website. I understand that your personal site should be a showcase for your Javascript skills, but I think adding audio cues to a blog is a step too far. The first time I visited this site, the sounds hadn't loaded in properly, and then it unleashed a buffer of ~20 bubble popping sound effects on my poor ears. Plus, the superfluous animation is tacky, and the centered text strikes me as an unbelievable waste of space. Sorry if that comes off as a bit rude (if it's any consolation, I liked your clay figure!), but I honestly prefer reading plain markdown on a white background.
- koverda 6y agoLuckily seems that the site supports reader view for people with your type of preferences.
- lvass 6y agoA lot of things including code snippets are missing on firefox' reader view.
- tshaddox 6y agoOn the other hand, I find his website to be among the most usable and enjoyable programming education blogs out there.
- girzel 6y agoIn my attempts to be a "generally competent programmer", I've waffled about how much web-dev technology I should reasonably expect myself to know. I think where I've come down is: knowing CSS well -- and yes, that means a real understanding of grid and flexbox -- but forgiving myself from Javascript. Anyone who might conceivably hire me to do anything JS related is likely to want the whole shebang: lightboxes, horizontal scrolling, SPA-like stuff, and I'm never going to be conversant with that. It's enough to be really good at CSS, and to save the JS for when people don't really realize you're writing JS: some little vanilla ECMA6 bumps to site usability, and maybe some tasteful htmx. That's enough. Leave the rest to someone else.
- DiggyJohnson 6y agoThis is exactly my approach, and I'm glad to see it written out so well.
- imbnwa 6y agoQuite honestly, as a self-taught frontend dev with only 5 yrs experience, everything about frontend is backwards in terms of priority. There are people who've been doing frontend for 15 years, so before the boom when it was a jQuery/Dojo/MooTools etc, who have no clue what a finite state machine is, never mind the implicit ubiquity in their business code. But asking about if people are familiar with React seems prioritous. Frontend is just stacked with this form of mistaken understanding, hence the bike-shedding over frameworks. We know we can represent a given app as a function signature, whose implementation would be comprimised of related, derived signatures, and a framework is just a bunch of implementation details between these in a sense. Details that may have profound significance for your project, but you'll be surprised how shallow the discussion resolves around those differences. This is why frontend is just piles of code on top of code, at least at operations I've seen, the JIRA ticket fest being another contributer, but there's so little engineering understanding being propagated by and large, people mistake these high-level concepts for software engineering proper. And somehow, the tech managers are usually the least in understanding, so they hire people who are like them and make them comfortable, and the process continues
- 6y ago
- Nailgun 6y agoI got into Javascript, the DOM, SVG, Canvas, WebGL but never CSS. I genuinely hate it with a passion. It is just one of those things that always annoy me and can't really explain why. I came from the Flash Runtime a long time ago where I used to easily control the display list. It might be that.
- heyparkerj 6y agoI've always been rubbed weird by CSS for these reasons: 1. Often times, someone will do something that should be done programmatically with CSS instead, leading me to finally come to the realization of "holy shit the bug was hidden in the CSS!". 2. I've (very cattily) referred to CSS as Cascading Sideeffect Sheets. You can do things to mitigate it, but trying to wrap your head around an application's vanilla CSS declarations and which elements are effected by what is an enormous pain compared to what it could be. My team has switched to CSS Modules, and the scoping relieves sooo much of my aversion to it. 3. The final reason is that CSS proficiency just feels like memorizing a collection of "Gotchas" that don't make sense in isolation. It's not very programmatic, and lots rules aren't grouped or named in a way that you can understand what's going on by reading. For every CSS rule you need to understand for whatever reason, you're going to have to dive into some documentation to figure out exactly all of the effects/sideeffects it will have, and sometimes also have to grok their interactions with other rules.
- Nailgun 6y agoI am totally feeling this! Especially your last point. I want to do something with B, but I break A and C somehow. Or I change A to fix B but all of A breaks down. I google it, and there is a menu of choices. On week 3 the first one worked, on week 6 it all breaks down, so I go back to A and C, but it breaks A again. I am really lazy with this. I feel like no one knows CSS properly, whereas for my previous listed technologies, you can learn it without the "shotgun" approach. I have always known I am missing something but never been able to put my hand on what that lightbulb is. Edit! Also due to the "menu" effect, when I do put my trust in someone, it doesn't actually apply. Like an OOP programmer using global constants everywhere! So what I learned was actually incorrect, but now I am polluted by garbage...
- knivets 6y ago> As JavaScript developers, the sheer amount of stuff we're expected to know is enormous, and it grows bigger every day. A question to ponder over: expected by whom?
- runawaybottle 6y agoThe pedantic circle jerk, why’d you ask? No one’s moving the needle other than the neurotics when it comes to this stuff. One of the few fraternities I’m ashamed to be apart of.
- eurasiantiger 6y agoBusiness requirements.
- notapenny 6y agoExpected by people themselves. Learn your fundamentals, get basic proficiency in maybe 1 or 2 frameworks and you're done. People drive themselves mad thinking they need to know everything. Most of "everything" is irrelevant, the rest you can pick up on the job.
- chrisweekly 6y agoJosh WC is cool, but if you want to (re)learn modern CSS and how to leverage it properly, from first principles, take a close look at "Axiomatic CSS" as described and demonstrated by https://every-layout.dev https://every-layout.dev -- a profoundly compelling, persuasive, expert, pragmatic, accessible, maintainable approach to CSS. It's transformative. I've been doing webdev since the late 90's (ie, before CSS), and this is hands-down the best such resource I've ever encountered. The axioms and some key examples are free; paying $100 for the book and component generator and access to updates was beyond a bargain. No affiliation, just a happy customer.
- pdamoc 6y agoSwitching to using stack and cluster has simplified my layouts tremendously.
- Taylor_OD 6y agoI just want to understand how to do pretty basic things with CSS. Like building hackernews in css even seems difficult. Anyone have suggestions?
- Kagerjay 6y agoAs someone who is usually the go-to CSS guy in every project, my take on CSS is you can't really master it. There's just so many tricks associated with it and our brains aren't wired to remember all the little tips and tricks. That being said, good skills in CSS are really in deficit imo. If your starting a career in webdev, just being good at CSS is already a big added benefit to a team, especially as a junior dev. Also, one of the harder things to understand as a frontend developer is knowing the limitations of CSS. It doesn't do everything, and sometimes you have to know when a Javascript-based CSS approach is better. This opens up another can of worms since now you also have to be familiar with alot of lesser known Javascript APIs. Last note to make is getting good at CSS also requires a good chunk of math knowledge, especially for difficult design-based problems
- DaiPlusPlus 6y agoI’m going to respectfully disagree with the “our brains aren’t wired” part: the most important part of the spec is the chapter of the visual formatting model which can be summarised as “each HTML element is a rectangular box” - that’s it. Simple to internalise for anyone new today and everything else builds on top of that. Though I admit it was difficult for me to internalise originally: I cut my teeth on HTML in 1999 when browsers still rendered each element type differently and they weren’t interchangeable. I couldn’t grok being able to make a <table> and a <h2> interchangeable from a styling perspective. The other parts of CSS, such as the cascading styles really isn’t that important - and I agree modern features like Flexbox and Grid do introduce more special-cases, but they’re no worse than having to understand how to abuse floats, clearing, and “replaced content” for website layout - I’m glad those concepts are gone.
- eyelidlessness 6y ago> I’m going to respectfully disagree with the “our brains aren’t wired” part: the most important part of the spec is the chapter of the visual formatting model which can be summarised as “each HTML element is a rectangular box” - that’s it. Simple to internalise for anyone new today and everything else builds on top of that. This is, respectfully, absolutely insulting to people actually working in CSS in real browsers. Okay fine, it's a rectangular box. When and where does it appear? Sometimes it's undefined. What properties does it have once it does? Hoooooly crap this is undefined. As a just today example: I discovered that two eventually overlapping linear gradients in Safari (checked in iOS) render differently after wake from sleep or dark/light mode switch. One of the gradients doesn't render at all before, and only renders in the portion of its "rectangle" after. Bug? Sure. Common-fucking-place-normal-ass-website-styling-shit? Yep. Edit to add the real kicker: it has nothing to do with the styles of the thing with the gradients on it! It has nothing to do with accommodating the children of the parent. It's just: one parent is a grid, the other is a flex. Nothing. At. All. Changes the outcome.
- taphangum 6y agoA big reason why many developers struggle with CSS is because they view it as an afterthought. And never truly learn the fundamentals. An article that talks about how to overcome this (and that many have found useful): https://planflow.dev/blog/how-to-get-better-at-css https://planflow.dev/blog/how-to-get-better-at-css
- hshshs2 6y agoOne important tip that I’ve found useful with CSS: read the whole MDN page when you’re looking up how to do something. I feel like my knowledge has increased dramatically just by doing that and it’s only a minor diversion.
- racl101 6y agoWhen I was first starting out I thought I really needed to be a Jack-of-all-trades before I could be hireable and/or a practicing programmer. I tried to study a lot of technologies but found that I was spreading myself thing and doing nothing exceptionally well. Instead, it served me better to work on a few projects, see what I like, pick an area and to just get better and then learn the other things I need to as I go along. Nobody can be good at every technology. It's not like that in real life so why do we have expectations that it would be like this in software development? A kickass mechanic doesn't need to be also be a kickass plumber and a kickass carpenter. They can but that's not what we expect from them. I am now comfortable knowing more server side technologies and barely scratch the surface of modern CSS. My efforts are rewarded more handsomely knowing backend technologies and JavaScript. If I need to know CSS then I can believe in my efficacy that I can learn it if I have time and to spend on it, and not feel insecure about delegating front end work to people who do it better.
- corytheboyd 6y agotailwindcss is such a godsend when it comes to styling. To anyone glancing at it thinking "this is trash it's just inline styles all over the place that encourages duplication" I implore you to actually read and think about the points raised here: https://adamwathan.me/css-utility-classes-and-separation-of-concerns/ https://adamwathan.me/css-utility-classes-and-separation-of-... tailwindcss effectively boils the dauntingly large control plane of every CSS feature down into "utility classes" that you then compose all styling from. So far, it has had a solution for every styling problem I have encountered, and in the cases it didn't, when I really thought about it I was trying to do something dumb anyway. I swear I am not affiliated with the project at all haha, I just felt such a relief after giving it an honest try on a project and I could very easily see how powerful it would be in many of my past projects had we access to it (and convinced the naysayers)
- wildrhythms 6y agolol I've seen many reactionary takes in my workplace from front-end engineers (or even on Hackernews) reacting to Tailwind as "this is just inline styles with extra steps!" ... no, "inline styles with extra steps" is what you're doing now with CSS: writing a hundred one-off ".container" classes and bundling that with a hundred other ".container" and ".wrapper" classes across a hundred different components in the app. Tailwind is revolutionary. It has completely changed the way I develop, and I will evangelize it at every opportunity. I've started migrating a major project to Tailwind, and for the first time I'm not horrified by having to deal with conflicting stylesheets, etc. Everything I need to know about how a component looks is kept in the component, where it should be, and the bundle size is smaller than ever because Tailwind can prune the styles down to exactly what I'm using. Tailwind is great, and shoutout to Adam Wathan's youtube channel- very helpful in learning how it works and convincing me to try it.
- vinger 6y agoAdam's success is a podcast success story. The patience required to slowly build up an audience by creating daily videos/postcasts that incrementally built an application or framework. Adam had success time and again but he always builds profits and abandons. PHP without loops, test driven laravel are two other successful audiences that were built, sold to and abandon. He has seemed to move on from refactoring ui. It has been a year+ since Tailwinds has been released. How much longer before Adam jumps to the next thing?
- jambutters 6y agoNot just css but the entire web is an abomination. We could have had a uniform language to express html, css, and javascript, and that is lisp/scheme/s-expressions. Instead we got javascript that has to hack and manipulate css and html because they don't/didn't have the notion of variables and loops. CSS is the absolute worst and just needs to die
- vfclists 6y agoMaking such comments on HN gets you downvoted. Name the culprits who are supposed to set standards, currently Google and Apple, with Mozilla and Microsoft trailing behind, and you will get downvoted into oblivion.
- Waterluvian 6y agoI find css is a ripe place for developers to potentially waste huge amounts of time building up DRY, cascading beauty that will never pay for itself.
- egberts 6y agoSaw a state-ful internal network port scanner using JavaScript-free CSS. Me think that anti-virus companies have got their work cutout for them.
- vfclists 6y agoCSS is not a programming language. If it was it wouldn't be called Cascading Style Sheets. A programming lets you specify initial state, final state, and the commands in the programming language required to go from initial state to final state. It is a system that enables something akin dividing by zero all over the place as though there is nothing wrong inherently wrong with dividing by zero. The impedance mismatch between how you describe what you want to see and how to express it in the language is so huge it is insane. It is part of the ongoing fraud of pretending that tying Javascript to a document layout languages is a sound way to script the presentation of data. If that was truly the case IBM and Xerox would have invented something close to that combo in the 60s and 70s. So long as Google and Microsoft earn money from their app stores they are never going to introduce a pragmatic for displaying information in the browser. It is over 10 years now since together with Apple they deprecated Flash and Silverlight, yet 10 years later with vastly improved hardware they still can't come up with a meaningful system than the same lame HTML5/CSS/Javascript.