Live data from Hacker News

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

news.ycombinator.com

81–90 of 358 posts

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

#81

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.

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

#82
post #5

>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_…

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.

Yes, this. So much this.

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

#83
post #76

The whole set of web technologies is a mess. We‘re still in the stone age of web UI design, similar to the 80‘s era of home computing when everybody built their own UI with basic drawing primitives. It’s going to take a while till decent, cross-platform/device UI libraries make progress and designers discover the value of reusable components that just work and are familiar to users. Until then, we‘re stuck with terri…

The sad thing is that by the 1990s we'd figured out how to do good UI design for desktops, but then we promptly forgot every single bit of that knowledge when the web came along.

In the mid-90‘s the web wasn’t that bad, people used normal buttons, unstyled links and basic tables. The downward spiral started when corporations came and wanted their “CI” styling, then designers came and wanted to be “creative” and turned web pages into minigames where you have to guess what color or text style denotes a link, what the icons mean and how to trick the infinitely-scrolling website into displaying the footer. ;-)

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

#84
post #57

CSS is almost a failure as technology. None of it's promises has been realized. The idea with CSS was that we would be able to separate content from presentation. Remember CSS Zen garden? Yet that has never been the case and div tags were always needed to be able to display something simple. Another promise was that content would be displayed easily on different mediums, desktop, mobile even print.. yet it's impossib…

Agree.

Worth noting that the real separation of content from presentation is JSON-data + a CSS/HTML hybrid front-end, often implemented as an off-the-shelf display framework (Bootstrap etc).

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

#85
It's not just you. Treating the web like a native UI framework, where you can set pixel positions directly to get the perfect layout, isn't going to work. The trick to using CSS effectively is to give up on achieving whatever design goal you have. Instead, you should settle for what CSS actually lets you do. Don't try to align text to the pixel; change your design so it doesn't require precise alignment. Ideally your designers should also work in CSS so they can understand why nothing looks exactly like the images they produce.

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

#86
CSS is not as difficult as many people think.

I believe part of the reason why developers have trouble with CSS is that they don’t ever try to write it from scratch. A lot of web development tutorials/courses/bootcamps often go in depth on JS and maybe HTML but always just slap in CSS frameworks to make things look nice as an afterthought.

I remember the first project I worked on as a web developer was to update the styles of an existing web app with very complex UI. It was hard as hell. But I was lucky to have worked with a senior developer who was a CSS wizard. He taught me that CSS is not magic although it is magical. If you don't give up, you can bring any designs to life.

Not knowing any better, I spent months playing, tweaking, learning how to style different components from scratch. I mastered selectors and the cascade, block model and floats, display and position types, a few tricks like using negative margin, constructing triangles from borders. I never stopped honing my skills. Before long I started learning about responsive design, transitions, animations, performance, and design systems.

CSS became a playground for me to experiment. It opened up a whole new world to express my imaginations. My advice for anyone aspiring to master CSS is to find some design inspiration that you like and just build it. You'll learn so much along the way if you don't give up. At some point, things will fall into place and you will realize just how wonderful CSS really is.

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

#87
I'd recommend spending some dedicated time learning about layout, not leaning on a framework.

CSS layout is largely about the relationship between elements. Instead of looking at it as "I want this element on the right," try to see the relationships between elements. What's the group of elements, and what causes them to be where they are? (Generally, complex layouts are nothing more than nested groups of elements.)

Once you recognize the patterns, CSS layout becomes straightforward. Not easy, but straightforward. It becomes a matter of defining and expressing the relationship between elements, and the constraints that define their layout. Flexbox is really the thing to focus on here. Don't worry about the words if you mix them up -- justify vs align, etc. Just the idea of a spacial relationship between things with rules that define the constraints.

Often times, the relationship winds up being expressed as "I want this group to consist of items with space between them on the current row they wind up on opposite sides of viewport, and when they wrap, I want everything aligned to the left."

Also, really understanding CSS is not about tricks, but if there's one thing that can help you gain an appreciation, it's learning how to write layouts that can handle arbitrary number of elements without any templating logic to add special case classes, e.g. for the first and last column in a grid. To this end, using equal but opposite positive and negative margins (negative on a container, positive on its children) can provide space between elements and allow for arbitrary numbers of elements within a layout where you don't care which is first or last in a given row. Let the elements flow into the layout.

I think there's a pretty definitive set of exercises any developer could work through to learn about the different types of constraints we need to express, and from there, it's generally a matter of recognizing the pattern in a higher-fidelity format.

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

#88

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…

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.

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

#89
CSS is great, but its poorly taught. I've known so many developers of all skill levels who get stuck somewhere between "I can make it red but I have no idea how to apply all these random properties into the layout I want." They'd ask me for resources, and I couldn't find one I thought was very good at that.

So I tried to write one.

https://whatisjasongoldstein.github.io/buildcss/

What's nice about this is I wrote it for real people, tested it on them, applied their feedback... etc. It's a little old now (this was before widespread Flexbox support) but it's specifically aimed at the sorts of problems you described.

Post reply on HN