Live data from Hacker News

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

news.ycombinator.com

171–180 of 358 posts

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

#171
post #107

> I have no idea which colors "go" with which ones, and pretty much all fonts look like the same for me. Can't help on the fonts thing here, but for colors, there are a couple of things to consider. You can use color wheels of different kinds to find matching colors and harmonious color palettes to create/use in a color scheme. There are many online sites that provide this for free. While deciding on colors, you shou…

Colorhexa.com shows you how the color you chose is perceived by people with color blindness.

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

#172
As a designer who often hands over designs to developers, I find it all too frequent scenarios where developers struggle interpreting design into code. I have NEVER seen a developer who can implement a design exactly per spec in CSS.

This is not to say that developers are incompetent with CSS, in fact, it probably says more about CSS than it does about the developer. The fact that CSS has gotten so convoluted is counter to its original goal.

Perhaps I have just work with companies who don't have an A-class developer team? I don't know. But it's not unusual for developers to straight up tell me "I'm not a CSS guy". Like... really? Who is then?

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

#173
I guess I'm alone in liking CSS.

Yes, it definitely takes years of experience implementing annoying designs to appreciate... But the macro-positioning stuff comes pretty easy once you understand the box model and can visualise the positioning.

I don't think it's an art. It just takes real experience.

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

#174
post #142

Earlier quoted context omitted.

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

> 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. And when you have to implement a email design someone gave you who think it’s more important to have it look a certain way then to implement it reliable.

That’s because the rendering engines in email software are crap, not due to a deficiency in CSS - I think Outlook still uses Word’s HTML renderer and even Gmail doesn’t support everything.

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

#176
post #88

Earlier quoted context omitted.

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.

You can accidentally use == instead of ===, or even accidentally use the assignment operator instead of one of the comparison operators.

You can know about for..in without knowing about hasOwnProp.

You can forget to enable strict mode.

The list goes on. Static analysis is universally a good thing.

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

#177
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…

Good comment.

CSS is actually pretty simple, as long as you start with the smallest elements and work up. It becomes a nightmare if you try and address everything individually. It’s not really a programming language, but a series of guidelines.

I’ve seen this simplicity actually throw developers as they’re used to something much more complex and systematic.

Preprocessors like SASS are great, but I wonder if they’re designed to complicate CSS a bit so developers feel at home.

Pixel perfect design is totally possible, as long as the designer is aware of the constraints and opportunities of the medium they’re working in.

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

#179
post #142

Earlier quoted context omitted.

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

> 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.

What's the advantage? The screen is 2D space. Layouting is a 2D problem. Images are two-dimensional. It's simpler to start from 2D and make 1D content fit that space than the other way around.

> The web is 1D because text is 1D.

That made sense in the very early days of the web, now it's just a historical crutch. I fully understand why things are the way they are, but that's orthogonal.

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

#180
The tipping point for me was memorizing "A complete guide to flexbox" from the site "CSS Tricks" by using flash cards (Anki).

The problems with CSS are:

- A lot of features have been abused before there were good layout features in CSS. *

- Errors are silent and you can repeat rules.

- Selector specificty is a major fail in the language IMHO. *

- Everything is global. *

* An example: floating an image is an excellent way of wrapping text around an image. Inline blocks are excellent for inserting layout in the middle of text. Neither are ideal for creating a layout. Flex and grid has now fixed that however.

What helps is to internalize the core concepts and to never "slap on another rule" when things just don't work. Start from scratch and update your mental model.

* CSS-in-JS bypasses the issue of global selectors. And when CSS is localized, specificity becommes a none-issue. Check out styled-components for either React or Vue. When IE11 dies and Edge turns Chromium, shadow DOM will probably become the standard way to solve this.

Post reply on HN