Live data from Hacker News

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

news.ycombinator.com

141–150 of 358 posts

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

#141
post #76

Earlier quoted context omitted.

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.

But the web wasn't supposed to be a UI platform - it was supposed to be a medium for delivering text with some images and media occasionally interspersed. Hyper text markup language. Java applets could use Swing to get a normal-ish desktop UI and still be close to the web. But we keep trying to cram a UI framework into HTML/CSS. The standards are slowly mutating and eventually they may provide a good UI framework. Ja…

I have been doing UIs since the mid-90's, with Turbo Vision being my first framework.

Naturally also Web based ones since early 2000's.

Share the feeling, everything is so much easier in native toolkits.

There is some hope though thanks to Web Components and Houdini.

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

#142
post #126

1) CSS is for implementing designs; being able to use it doesn't require design sense for things like colors 2) I'm fascinated by the fact that so many of my fellow programmers - often the smartest ones - have so much trouble with CSS. I'm not sure exactly what the reason for that is, though I did write an article hoping to address it in some capacity: https://css-tricks.com/css-is-awesome/ I think part of the proble…

CSS is not a real constraint language. If it really were a constraint language, it would be better. There's no constraint solver. Just a bunch of rules applied sequentially. I'd like to have a real constraint system, like the one in Autodesk Inventor sketch mode. You select two things and apply a constraint - parallel, tangent, horizontal, collinear, etc - and the constraint system enforces those constraints. The lay…

> Amusingly, tables came back. But they're called "layout tables" now, to avoid embarrassment.

I'm not really sure what you're talking about. Tables were bad because they were too rigid and weren't designed for layout purposes; they do still get used when you want to display an actual table. Maybe you meant CSS Grid?

> Trying to do 2D layout with 1D constructs (the "float" and "clear" era) was just silly.

The float era was certainly a dark time, and I'm glad I came into the field on the tail end of it. It was a hold-over from CSS' document-focused origins. Today we have flex-box, which quite elegantly serves 90% of people's layout needs, and CSS Grid which fills in the rest. For the record, flex-box is a 1D construct for doing 2D layouts, and it does the job fantastically.

Your Autodesk comparison belies a fundamental misunderstanding about the nature of the DOM - it is, to its great advantage, a 1D space which flows into a 2D shape. In fact, this was the great flaw with using tables for layout in the first place. By making the content fundamentally 2D, all it could do to respond to different screen sizes and different browser window resizes is stretch. But you don't actually want your layout to be totally percentage-based. You want your content to wrap and flow to make the best use of the available space that it can, with no assumptions about screen size or ratio. The web is 1D because text is 1D. As text flows in lines, within containers which may be different shapes and sizes, so does the entire document model. This is profoundly powerful. Modern CSS gives you the tools to make select aspects of your layout work differently - yes, even in 2D ways - but they're best used to shape and guide that fundamental flow instead of replacing it.

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

#143
> Is CSS an "art" thing?

No, but it helps to enjoy and respect visual layout challenges. Without appreciation of design, particularly web UI, you won't have much to aim for except MVP.

With programming, you are not usually switching back and forth between code and some visual layout element. CSS on the other hand, is an endless game of tweak, refresh, repeat. It's not for everyone.

BTW, Flexbox is now widely supported, and is much nicer to work with than trying to float DIVs, which nobody ever liked or found easy. Flexbox provides a nice way to center your elements horizontally and/or vertically, not to mention very nice control of spacing and item-level responsive sizing with flex-shrink.

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

#144

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…

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…

I remember slicing designs in Photoshop into sections, to be dropped into pages...gross.

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

#145
post #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.) O…

This is 7+ years old, but once I learned about flow and the box model, things generally made a lot of sense.

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

#147

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.

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

#148
post #88

Earlier quoted context omitted.

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…

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.

Post reply on HN